How to Use Screen in Linux
Screen provides virtual terminals that can continue running even when the the user has logged off or disconnected from the session. New sessions can be created at any time and can have different programs running in them.
Screen is installed by default in Ubuntu Linux and other Linux distributions. The source code for screen can be downloaded from the GNU website.
Screen can be started by running the command:
Session names can be added to the screen sessions to make it easier to reattach later with the -S option:
screen -S mysql
A list of screen session that have been created can be displayed by using the -ls option:
bill@K11:~$ screen -ls There is a screen on: 17260.mysql (30/08/11 16:19:57) (Detached) 1 Socket in /var/run/screen/S-bill.
A session can be reattached if it is not attached. To reattach a screen session, the screen command is used with the -R option to reattach the last detached session or the -r option with the process id or name the session was given:
screen -r mysql
There are commands that can be used from with in screen:
|Ctrl+a c||New screen session.|
|Ctrl+a n||Next screen session.|
|Ctrl+a p||Previous screen session.|
|Ctrl+a “||Select a screen session from a list.|
|Ctrl+a Ctrl+a||Previously viewed screen session.|
|Ctrl+a S||Split screen into horizontal regions.|
|Ctrl+a |||Split screen into vertical regions.|
|Ctrl+a :resize||Resize regions.|
|Ctrl+a :fit||Fit screen to new terminal size.|
|Ctrl+a tab||Switch to next screen session.|
|Ctrl+a d||Detach from session.|
|Ctrl+a A||Set a window title.|
|Ctrl+a x||Lock screen session with a password.|
|Ctrl+a [||Scroll and copy mode.|
|Ctrl+a ]||Paste the buffer.|
|Ctrl+a >||Write the paste buffer to a file.|
|Ctrl+a <||Read a file to the paste buffer.|
|Ctrl ?||Show screen help.|
|Ctrl :||Screen command prompt.|
A screen session can end with the following command:
Sessions can be detached and resumed later either pressing Ctrl+a then d or just closing the window if in a graphical user interface.
More information can be found on screen at Screen User’s Manualor by using the following command:
Comments are currently closed.