GNU Screen, a.k.a, Linux Screen or Screen is a Linux tool for efficient management of command line terminals. It creates virtual terminals so that the same actual terminal is used simultaneously for multiple processes.

Installing screen

To install screen on Ubuntu and Debian, run:

sudo apt install screen

Note: For older Ubuntu versions (version 14.04 and below), you need to use apt-get should be used instead of apt.

To install screen on CentOS and Fedora, run:

yum install screen

Using screen

To run screen and open a virtual terminal, use the command:

screen

It outputs the info page of screen. Press Enter to switch to the virtual terminal. This will make the terminal screen switch to the virtual terminal, hiding the original terminal screen.

Linux screen commands

screen has a rich set of commands to handle the virtual terminals. These commands are run using modifier key combinations.

Ctrl + a is the key combination used to invoke the listener of the virtual terminal to listen for screen commands.

Note: When Ctrl + a is typed, the listener is invoked, however there will not be any output printed on the terminal. Similarly after we type a command for the listener to listen, it is silently typed and not displayed on screen.

  • Ctrl + a c: Create a new terminal window within screen.
  • Ctrl + a ": Shows list of screens. User can move through the list and press enter to open any available screen sessions.
  • Ctrl + a ': Ask for terminal identifier (name) and switch.
  • Ctrl + a [0...9]: Switch to terminal no. (Num) [0…9].
  • Ctrl + a A: Set a title for the current terminal.
  • Ctrl + a d: Detach a terminal from screen.
  • screen -r: Reattach the terminal to screen. In case of multiple detached virtual terminals it will print all of them and ask which one to reattach.
    Note: This command is typed on the terminal, and not using the modifier key listener as user is himself out of the virtual terminal, where key listener is no longer active.
  • Ctrl + a D: Detach the terminal and logout.
  • Ctrl + a i: Information about the current terminal.
  • Ctrl + a H: Start logging stdout of the current virtual terminal to a log file.

To exit the virtual terminal, press Ctrl + D.

screen has lots of other such commands. Read the man page of screen to know about further commands and features.

man screen

🍻 Cheers!