Software By JeffMain Page | About | Help | FAQ | Special pages | Log in
The Free Encyclopedia
Printable version | Disclaimers


From Software By Jeff

Screen is a valuable tool to extend shell sessions. It provides some session security, preventing loss due to disconnection. It also allows multple shell sessions at the same time through the same connection, with simple switching and copying between each.

This should help make screen more useful from the start.

Table of contents

Starting Bits

For most of the modern Linux distributions, screen is probably installed by default. If not, it'll certainly be available in the distribution's software repository. If not, here's some links to get it and get it going.

The screen homepage:

The screen manual:

Starting Screen

To simply start a new screen session when connected to a system with a terminal program (e.g., PuTTY or other SSH): screen

Even better, to reconnect to existing screens (or create a new one if it doesn’t exist): screen –DR

To see if you’re already running a screen: screen -list

Most of the time, screen –DR is the way to do it. Shell (SSH or TELNET) to a system, type screen –DR and you should be presented with a screen-wrapped shell session. Work there instead of in the raw shell. Then if you close the terminal window (accidentally or on purpose), the network drops, or any other flake occurs, the work is still in-progress on the remote system and waiting for your return.

Start-up Configuration

Create a file in your home directory named .screenrc and put these bits in there, and you’ll be able to tell when you’re in a screen. Other bits are described in the documentation, and hints follow.

shell -bash
shelltitle "$ |bash"
hardstatus on
hardstatus alwayslastline
hardstatus string ' [ %H ] %{wb} %c:%s | %d.%m.%Y %{wr} Load: %l %{wb} %w '
defscrollback 50000

The options in the file are plentiful, especially when looking for what the hardstatus bits mean.

Working with screen

These are the used-constantly bits. Much, much more available in the documentation.

In screen, the default hot-key is Ctrl-a. You can change that in the .screenrc file if you want to (see the "escape" option in the Command-Summary page above). To be clear on notation, "Ctrl-a a" means to hold control, tap a, release control, tap a again, of course.

To send hot-key to your program (instead of letting screen eat it): Ctrl-a a

To exit screen, there are a few options. These are very frequently used:

That last is useful when you’re using PuTTY or SSH to connect to the server, start screen, and then don’t need the shell again—PuTTY or the terminal running SSH will close. The alternative is that you’ll exit screen, and still be in the shell, so you’d have to exit that shell to close PuTTY or end the SSH session. If you’re on a Linux box, SSH’d to another box, you’ll have to open the terminal, SSH to another box, be at that prompt, enter screen…and exit each of those; power disconnect closes that first terminal! It does leave the screen running, so when you return to that server and restart screen (with –DR) it’ll reconnect and leave you where you were.

An evil little bit of confusion there as older screen is still there, but dirty, but it looks like it cleared because of the new screen that appears.

When working with multiple screens:

One evilness in screen is that the scrolling in your terminal window is disrupted; no more useful scrollbars. Because screen is maintaining its buffer internally, the terminal scroll window doesn’t really have much to do with the scrollback buffer. Curiously, even though it does this, it offers no navigation mechanism! One easy trick to navigate around in screen is switch to copy-mode and use the arrow keys instead of the mouse.

Another benefit screen gives in this area is that if you resize the window, the screen contents resize with it. This can get a little quirky if you resize while running an interactive program (like vim) because that program will have dealt with the resizing, but the shell underneath will not. Quick cure when that funkiness becomes apparent is to resize the window again (even if it’s just grab the frame and drop it).

Retrieved from ""

This page has been accessed 6361 times. This page was last modified 15:53, 4 May 2010.

Main Page
Community portal
Current events
Recent changes
Random page
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Page history
What links here
Related changes
My pages
Create an account or log in
Special pages
New pages
Image list
Bug reports