Skip Links

Network World

  • Social Web 
  • Email 
  • Close

(Comma separation for multiple addresses)
Your Message:

An introduction to GNU screen

By Brian Tanaka, LinuxWorld.com
October 03, 2006 02:13 PM ET
  • Share/Email
  • Tweet This
  • Comment
  • Print

If you want to use desktop real estate more efficiently or if you ever find yourself without the X Window System yet needing more than one terminal, the popular GNU screen utility may be the perfect solution.

Screen enables you to run multiple processes -- such as interactive shells, text editors, web browsers or e-mail and irc clients -- multiplexed within a single terminal. You may have tried achieving the same result with tabbed terminal emulators such as gnome-terminal or Konsole, but screen boasts a long list of advantages over tabbed terminals.

In fact, screen has so many features, its man page is more than 20,000 words long! Obviously, though this story provides everything you need to begin taking advantage of screen's power, it only scratches the surface of this unusual and versatile tool. You're encouraged to read the man page and to experiment. To quote the man page: "A weird imagination is most useful to gain full advantage of all the features."

It's likely screen is already installed on your Linux computer. If for some reason it's not, use your distribution's package management system to install it, or visit here to acquire and install the latest version.

Let's try out some basic screen skills. Open a terminal window and type screen at the shell prompt. Depending on how screen was compiled, you may see a welcome message. Otherwise, you will simply see a new shell prompt. If you receive the welcome message, press space or return to continue.

Screen is now running. It doesn't look like much yet because it has simply created a single window with a shell in it. You may use this window immediately. As you create more windows, screen assigns a number to each. This first window is number 0. Subsequently created windows will be numbered: 1, 2, 3, and so on.

Create a new window now by typing the screen command for create. All screen commands begin with control-a, which the Screen man page abbreviates to C-a, and are followed by an additional keystroke. For example, to create a new window, type: C-a c. For purposes of this exercise, please create two new windows with C-a c.

To see a list of windows, type C-a w. Notice that screen has used the last line of your terminal to display a list of windows. You can tell which window is active because it is marked with *. Another way to see the list of windows, is to type C-a ". A list of windows appears, and you can navigate among them by using the arrow keys or vi movement keys. Press enter to bring the currently highlighted window to the foreground.

Switching to the next window is easy. Type C-a n. Type the next command again and screen will switch to the next window. When you type C-a n from the highest numbered window, you will wrap around to window 0. To move the other way, switching to the previous window rather than the next, Type C-a p. If you have many windows, it may be easier to use C-a " than next and previous.

Now that you've played with navigating among your windows, you may feel that the default window titles aren't very helpful. Fortunately, they're easy to change. To set the title of a window, navigate to the window you'd like to change and type C-a A. (Note that you must use capital A. Lower case a has a different meaning.) Set the title of a window now, and then use C-a " to list your windows. Note that your new title appears in the list. It will also appear in the output of C-a w.

  • Share/Email
  • Tweet This
  • Comment
  • Print

Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a NetworkWorld account? Log in here. Register now for a free account.

Videos

rssRss Feed