Screen Tips for Linux users

Screen is Linux window manager program which helps users to a have a window session open with multiple shells/tabs. Screen will start a process that continuously runs on the server. User can open multiple tabs/shell within the main Session to switch between different tabs/shell.

Screen is useful when:
•    You want to run a program which can take long time to complete.
•    You have an internet connection that often drops.
•    You want to work with multiple servers and do not want to have different putty shells opened.
•    You want to save the work environment on each servers and came back on each day and start the screen to get the session connected to the servers where you left off.

Example: I want to start a process and check it status at a later time.
You can use nohup or start the process in background. But if the network is disconnected, you may not get the same shell which I started the process. Here come screen for you. Start the process from after starting the screen session, detach the screen and close your putty connection. You can check the status of the started process by re-attaching the screen session at a later time by connecting the putty. Once the process is started with the screen session, there is no need to bother about the internet connection to the server unlike when you run the process from a normal shell prompt.

Few are some of the useful commands using screen:
#start screen session with name session_name and tab titles with name title_name
$screen -S session_name -t title_name
#to detach the session and resume
$screen -r -D session_name
#to resume a detached session
$screen -r session_name
#to kill a detached or not responding screen session with name screen_session
$screen -r screen_session -X quit

Some useful key bindings:
Ctrl+a+d  => Detach the screen session from the current shell.
Ctrl+a+c => Create a new tab/window within the session
Ctrl+a+n => switch the screen in forward mode
Ctrl+a+p => switch the screen in backward mode
Ctrl+a then shift+a => To change the title of the tab/window

Below is the .screenrc file which I use in my day to day work.
cat ~/.screenrc
#scrollback control lines
termcapinfo xterm|xterms|xs|rxvt ti@:te@
# Kill the annoying flickering on key presses
vbell off
#screen title captions format displayed at the bottom
caption always '%H %c | %-w%{=}%n-%t%{-}%+w'

________________________________________
More detailed information on Screen can be found at http://www.gnu.org/software/screen/manual/screen.html