July 18, 2015

Useful Linux command : screen

Posted on July 18, 2015  •  2 minutes  • 290 words  •  Suggest Changes

Screen is one of those hidden Linux gems, when working on a remote or unstable connection, screen is the way to go!  It creates a new shell that keeps on running even when you disconnect.

Using screen is as simple as typing screen there are some options, those however, I commonly don’t use, with one exception, the -S parameter, which gives you the option to enter a human readable name for the screen session. Definitely useful for long running jobs you are sure you are going to detach ! Another one is the -r option to reattach again (when your link was down, and you had to reconnect). In the default run-mode there is no log being made of the screen session and the scrolling-back history buffer is rather limited, so when rsyncing for example it might be useful to log the output. This can be done using the -L flag, note that you can set the scrolling-back history buffer (-h int) also, but this is limited anyway, so its better to log the screen. To end, some examples.

# simply start a new screen session

# start a screen session with a name
screen -S my_names

# detach from a screen
ctrl-a ctrl-d

# reattach on a screen
screen -r pid.screen_name
screen -r 14552.rysnc_to_server
screen -r 14809.pts-0.localhost
# screen list
screen -ls

# when a screen is attached, and you can't enter
screen -D 14552.attached_screen
# screen with logging
screen -L

# sometimes the screen "locks up" "freezes" you can try
ctrl-a q
# which is unblocking scroll


One of the features I know exist but forget how to use is scrolling in the screen; To scroll use :


If you enjoyed this website, consider buying me a Dr. Pepper

Buy me a Dr PepperBuy me a Dr Pepper