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:
Commands | Description |
---|---|
screen –version | Check installed screen version |
screen | Opens a screen session, creates a new window, and starts a shell in that window |
screen -S | Starting Named Session Named sessions are useful while running multiple screen sessions |
screen -d | Detach the elsewhere running screen |
screen -r | Resume or reattach screen session |
screen -ls | Find 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
Command | Description |
---|---|
Ctrl+a, ? | Get list of available screen commands |
Ctrl+a, c | Create a new window (with shell) |
Ctrl+a, “ | List all windows |
Ctrl+a, 0 | Switch to window 0 (by number ) |
Ctrl+a, A | Rename the current window |
Ctrl+a, S | Split current region horizontally into two regions |
Ctrl+a, | | Split current region vertically into two regions |
Ctrl+a, tab | Switch the input focus to the next region |
Ctrl+a, Ctrl+a | Toggle between the current and previous region |
Ctrl+a, Q | Close all regions but the current one |
Ctrl+a, X | Close the current region |
Ctrl+a, d | Anytime, 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}]'