Tuesday, November 25, 2008

Using gnu screen

Screen is a full-screen window manager that multiplexes a physical terminal between several processes. In short, you can have a few virtual terminal by using only one physical terminal. Screen is useful when you are accessing servers remotely, or running jobs on the background. When you want to run jobs on the background, it is very useful to run it inside one screen so that you can detached it, and simply log out without worry. Below are a few useful command to be used with screen to get you started.

To start using screen
# screen

To start using screen with sessionname
# screen -S sessionname

To list out all available screen
# screen -ls

To attach to a detached screen
# screen -r

To attach to a detached screen with certain pid
# screen -r pidnumber

To attach to a non detached screen session (multi display mode). Using this mode, you can make other people see what you are doing on your screen
# screen -x

When inside screen:

To kill current screen
ctrl-a k

To detach current screen
ctrl-a d

You cannot use the scroll function when inside screen. To scroll, you have to use screen's copy mode, then you can scroll up or down using your arrow key, pageup and pageup. To exit copy mode, press 'Esc'. To enter copy mode:
ctrl-a [
or
ctrl-a Esc

To monitor terminal for activity (start or stop)
ctrl-a M

To monitor terminal for 30-seconds silence (start or stop)
ctrl-a _

Give name to the terminal
ctrl-a shift-a

View all opened screen (interactive)
ctrl-a "

View all opened screen (non-interactive)
ctrl-a w

Move to the next screen
ctrl-a n

Move to the previous screen
ctrl-a p

Move to screen number
ctrl-a N where N is the number of the screen

Lock screen
ctrl-a x

Kill all windows and terminate screen
ctrl-a \

View help for screen
ctrl-a ?

1 comment:

adli said...

I think screen is the most rockstar app after xterm/bash :-). I can't think of ways to survive the 24x7 internet connectivity without it.