Screen: All in one
Submitted by Swobodin on Tue, 2006-11-14 13:26. ::
(I learned these tricks via /etc/shadow)
Ever connected to a remote host and needed more than one terminal for a specific task? Every UNIX administrator does, but not all the admins know about screen, as many of them tend to open many login sessions. Aside from the loss of time that causes the previously mentioned operation, every new shell session takes averagely 6 to 8 MB of RAM on the local machine, hence the need for multiple shell windows inside a single session.
Assuming that the remote host you are working on has screen installed (which is almost always the case), connect on your ssh (or telnet) session
Start a new screen session
Now, you logged in a new screen terminal, which allows you to perform the same operations as in a normal session, yet with other features that can be ran with shortcuts.
Ctrl+a, c (without comma "," Hold Ctrl and A simultaneously, then release and press C in lowercase)
You may rename the window:
Ctrl+a, A (please note, "A" is in uppercase)
Below you will be asked to enter the new title
To switch between windows:
Ctrl+a, d
The windows will work in background, and won't bother you with output and error messages. This is a good idea if you want to disconnect from the remote host and "let the machines do the dirty work".
To reattach a screen (you are in the parent window now), detect its process id, terminal and host
Choose the one you want to connect on, and reattach it with -r option
Ctrl+a, x
You will have to type your username password in order to return to the session.
Logging output
Ctrl+a, H (uppercase)
All what you type and all what the terminal outputs will be logged in screenlog.n , where n is your window number
Ctrl+a, K
A prompt menu will you ask you whether you are really willing to kill the window (stupid question, but I don't find an alternative)
To kill the whole screen and the parent session (be careful as you won't have to confirm, all your work will go away)
Ctrl+a, D, D
Show system information
Ctrl+a, v
Display the version and compilation date.
Ctrl+a, ?
Show bind keys, all what you need is there.
Ever connected to a remote host and needed more than one terminal for a specific task? Every UNIX administrator does, but not all the admins know about screen, as many of them tend to open many login sessions. Aside from the loss of time that causes the previously mentioned operation, every new shell session takes averagely 6 to 8 MB of RAM on the local machine, hence the need for multiple shell windows inside a single session.
Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Each virtual terminal provides the functions of a DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.Too much theory, now, let's proceed on.
Assuming that the remote host you are working on has screen installed (which is almost always the case), connect on your ssh (or telnet) session
ssh swobodin@192.168.0.1Start a new screen session
screenNow, you logged in a new screen terminal, which allows you to perform the same operations as in a normal session, yet with other features that can be ran with shortcuts.
Creating, renaming windows, moving between windows
Open a new window into the screen sessionCtrl+a, c (without comma "," Hold Ctrl and A simultaneously, then release and press C in lowercase)
You may rename the window:
Ctrl+a, A (please note, "A" is in uppercase)
Below you will be asked to enter the new title
To switch between windows:
- Ctrl+a, <window_number>
where <widow_number> is a digit in the range of 0 to 9 representing the number of the window, 0 stands for the first one. - Ctrl+a, space
Moves to the next window - Ctrl+a, "
Lists the windows and you may select with arrows and Enter keys - Ctrl+a, Ctrl+a
Toggles between the actual window and the previous one - Ctrl+a, Ctrl+'
Type the window title and you move there
Detaching, reattaching windows
To detach a screen and come back to your parent session:Ctrl+a, d
The windows will work in background, and won't bother you with output and error messages. This is a good idea if you want to disconnect from the remote host and "let the machines do the dirty work".
To reattach a screen (you are in the parent window now), detect its process id, terminal and host
$ screen -d
There are screens on:
7160.pts-1.host1 (Detached)
7111.pts-2.host1 (Detached)
7071.pts-1.host1 (Detached)Choose the one you want to connect on, and reattach it with -r option
screen -r 7160.pts-1.host1Locking sessions
To lock a session and requiring a login/password to reconnect (I like this feature), typeCtrl+a, x
You will have to type your username password in order to return to the session.
Logging output
Ctrl+a, H (uppercase)
All what you type and all what the terminal outputs will be logged in screenlog.n , where n is your window number
Kill, suicide
You may want to kill the screen you are working onCtrl+a, K
A prompt menu will you ask you whether you are really willing to kill the window (stupid question, but I don't find an alternative)
To kill the whole screen and the parent session (be careful as you won't have to confirm, all your work will go away)
Ctrl+a, D, D
Miscellaneous features
Ctrl+a, tShow system information
Ctrl+a, v
Display the version and compilation date.
Ctrl+a, ?
Show bind keys, all what you need is there.




Recent comments
3 years 31 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 40 weeks ago
3 years 40 weeks ago
3 years 40 weeks ago
3 years 40 weeks ago
3 years 41 weeks ago
3 years 41 weeks ago
3 years 41 weeks ago