Howto | Linux Screen

Screen in Linux provides ability to launch and use multiple shell sessions from a single ssh session. The process launched from the screen can be detached from session. The processes started inside the screen continues to run even it is detached from the session. The process can then re-attach the session at a later time. 

Screen can be used in the following ways:

screen –versionCheck installed screen version
screenOpens a screen session, creates a new window, and starts a shell in that window
screen -SStarting Named Session
Named sessions are useful while running multiple screen sessions
screen -dDetach the elsewhere running screen
screen -rResume or reattach screen session
screen -lsFind session ID list the current running screen sessions
pkill screen
killall screen
Kill or close all the screen sessions

Following set of commands are available inside screen

Ctrl+a, ?Get list of available screen commands
Ctrl+a, cCreate a new window (with shell)
Ctrl+a, “List all windows
Ctrl+a, 0Switch to window 0 (by number )
Ctrl+a, ARename the current window
Ctrl+a, SSplit current region horizontally into two regions
Ctrl+a, | Split current region vertically into two regions
Ctrl+a, tabSwitch the input focus to the next region
Ctrl+a, Ctrl+aToggle between the current and previous region
Ctrl+a, QClose all regions but the current one
Ctrl+a, XClose the current region
Ctrl+a, dAnytime, detach from the screen session

Screen Customization

screen reads its configuration parameters from /etc/screenrc and ~/.screenrc when started if the file is present. This preferences can be overridden using the .screenrc file.

Sample ~/.screenrc configuration with customized status line:

# Turn off the welcome message
startup_message off

# Disable visual bell
vbell off

# Set scrollback buffer to 10000
defscrollback 10000

# Customize the status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'