Useful Tricks With Screen

screen is a very useful program which in effect gives you multiple console screens in the same window. It's handy if you're using a console rather than an xterm, or if you're connected to another machine, as it means you can do multiple things at once without having to move to another console or open another ssh connection. Even more useful if you're working remotely: If your connection falls over while you're still in a screen session, you can ssh back to the machine and reattach the screen (with screen -r) and get straight back to where you were, rather than having to start over.

Tip of the Trade: Screen brings multiple console screens to the same window, enabling several tasks to be performed simultaneously and simplifying troubleshooting.

You can also manually detach the screen, with screen -d (detach screen), or by hitting Ctrl-A then D while in a screen session. This leaves the screen running in the background, and it can be useful for running background jobs. Or you can leave a screen session connected to another machine: Run screen before you open the ssh session, then instead of logging out when you're done, detach the screen, and then just reattach it (screen -r) when you need to connect to that machine again. The downside of this is that it does have security implications!

A final screen trick enables you to remotely look over a user's shoulder if you're trying to fix a problem.

xclip /path/to/file
Log on to the user's machine as him, then type
screen -S debug
Then, get him to type
screen -x debug
and he'll join your screen session. After this, whatever he does will be replicated on your screen (and vice versa). ('debug' is the identifier; any other name would also be fine.) This can save a lot of time when trying to track down a problem or to explain a solution!

This article was originally published on Jul 6, 2009
Page 1 of 1

Thanks for your registration, follow us on our social networks to keep up-to-date