1. Home
  2. Linux

Ubuntu: how to use Screen [Guide]

Screen is a handy tool as it allows users to save and come back to terminal sessions without having to keep the terminal window open. While many Linux users use this software on Linux servers, it can also be useful to Ubuntu users who want to always come back to a terminal program without having to keep the terminal open at all times.

Ubuntu: how to use Screen

In this guide, we’ll show you how to install Screen on Ubuntu, how the program works, and how to use it too. 

Ubuntu: how to use Screen – Installation

Although Screen is one of the most used terminal session managers on Linux, it doesn’t come pre-installed on Ubuntu. To use it, you will need to install it on your computer manually. 

To start the installation of Screen on your Linux PC, open up a terminal window. To open up a terminal window on the Ubuntu desktop, press Ctrl + Alt + T on the keyboard. Alternatively, search for “Terminal” in the app menu and open up the program that way.

Once the terminal window is open and ready to use on the Ubuntu desktop, use the apt install command below to install the Screen application. 

sudo apt install screen

Don’t want to install Screen via the terminal? You’ll also be able to find it in the Synaptic Package Manager. If you’ve got Synaptic installed on Ubuntu, click “Search,” type in “screen,” and install the package.

Ubuntu: how to use Screen – Keybindings for Screen

Screen has a lot of keybindings you will need to understand if you want to use the program. Each of the keybindings will help you use Screen to manage your terminal sessions on Ubuntu. 

There are a whole lot of keybindings for Screen. So many that if we posted them in this article, it’d take up half the page, so we can’t show them here. However, you can view the Screen keybindings yourself by doing the following.

First, use the man screen command to view the manual for the Screen application. This manual is very long, but it details everything there is to know about the app.

man screen

Once inside of the Screen manual, press the Spacebar button till you get to the “DEFAULT KEY BINDINGS” section. From there, read the keybinding table to familiarize yourself with Screen.

Want to view the keybinding info in your favorite text editor? Export it to a text file in your home folder with the command below.

man screen > ~/screen-manual.txt

Open up “screen-manual.txt” to view it.

Ubuntu: how to use Screen – Basic use of Screen

Screen is a very advanced program, despite its small installation size. In this guide, we’ll cover the fundamental elements of it, such as how to activate Screen, how to send terminal sessions to the background/foreground, etc.

To start, launch the Screen application in the terminal. To do that, execute the following screen command.

screen

Once you launch the Screen app, you’ll see a brief message talking about the program’s copyright and capabilities. From here, press the Space button on the keyboard.

After pressing Space, you’ll be presented with a blank terminal. However, this terminal is running through Screen. From here, you can launch any program. For example, to run the Top app in Screen, you’d run:

top

To send the Top app to the background and open up another terminal, press Ctrl + A  followed by C. This keyboard combo creates a second terminal and keeps Top running, but in the background.

To get back to the Top app, you can press Ctrl + A, then the Ctrl + A a second time. This button combination will swap you back to the Top running in the first terminal opened in Screen. You can press Ctrl + A twice to go between the two running terminal sessions in Screen.

If you have more than 2 Screen terminal sessions, pressing Ctrl + A twice won’t navigate you through all of them. To navigate through multiple sessions, do the following.

First, press Ctrl + A, then to list your Screen terminal sessions. Then, look at the list and note the numbers next to it. For example, if you have 3 Screen terminal sessions open, the list prompt (when pressing Ctrl + A then W) will look like the code below.

0*$ bash 1$ bash 2-$ bash

Each Screen session has a number next to it. For example, to navigate to Screen session 0, you’d do Ctrl + A then 0. To access Screen session 2, you’d press Ctrl + A, then 2, etc.

Kill a Screen terminal session

Need to kill an active Screen session? Here’s how to do it. First, list out the sessions available by pressing Ctrl + A, then W. Then, access the session with  Ctrl + A, then the Ctrl + #.

Once inside of the session you wish to kill, press Ctrl + A then K. Alternatively, kill all of your Screen session windows with Ctrl + A then \.

More information on Screen

In this guide, we covered the very basics of how to use Screen in Ubuntu. If you’d like to learn more about the app and access some of its more advanced functions, you’ll need to read the manual. 

To read the Screen manual, open up a terminal window and enter the command below.

man screen

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.