Using GNU Screen

GNU Screen is a terminal multiplexer. You can use it to run multiple instances of a interactive shell in the same "window." It is the same concept as running multiple tabs on a web browser. Instead of clicking on a "+" symbol to create another tab, you use keyboard shortcuts. You can also detach and reattach screens as you like. Another feature of Screen is that it will keep programs running if you accidentally close the terminal. Screen function has been installed on the Bishop server; if you would like to use this feature, SSH into Bishop to use it.

Starting Screen

Start Screen by typing "screen" into the command. At the top of your terminal, you'll see [screen 0: shell] username@bishop on the title of the terminal. This means you have successfully started Screen. Now you are able to create new Screen windows and use other features of Screen. Create new windows by pressing ctrl+a and then type in "c" and hit enter. You'll notice that the terminal flashes and [screen 1:] becomes the title of your terminal. This means you have created a new screen. You can shift through your screens with several different shortcut commands:

  • ctrl+a n -- switch to the next screen
  • ctrl+a p -- switch to the previous screen
  • ctrl+a 0-9 -- the numbers are displayed on the title of the screen

Detaching and Reattaching

You can use Screen to run programs and close them so they run in the background. In order to do this, run the program in one of your Screen windows and detach the screen by pressing ctrl+a and typing "d" and press enter. You'll notice that you are back into the original terminal that you started Screen in. To bring back the screen you detached, type "screen -r" in the terminal.

Keyboard Shortcuts

The following are some of the common shortcuts you can use while using Screen. All shortcuts in Screen are preceded by ctrl+a and are case-sensitive.

  • c -- creates a new window
  • 0 through 9 -- switches between windows
  • n -- switch to the next window
  • p -- switch to the previous window
  • A -- change the name of the window
  • d -- detach the current screen
  • K -- kills the current window
  • list -- lists all the screens

For more detailed information about shortcuts, run the command man screen in your terminal.

Closing Screen

In order to fully close Screen, you have to close every screen that has been opened; otherwise, it will keep running in the background. You can check if all the screens open by entering command screen -list.