Up to $100 off Dedicated Servers

How to Use the Screen Command in Linux

Posted on by J. Mays
Reading Time: 2 minutes

Screen is a terminal program that allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program.

Similar to VNC, screen allows the user to start applications from one computer, and then reconnect from a different computer and continue using the same application without having to restart it. This makes migration between locations like work and home simple. Screen provides terminal-agnostic functionality so that users can disconnect and reconnect using different terminal types, allowing applications to continue running without being aware of the change in terminals. This functionality can be extremely useful in monitoring a task or script that will take a long time to run.

Screen allows multiple computers to connect to the same session at once, allowing collaboration between multiple users.  This functionality can be useful as a training tool.  Allowing multiple users to connect to the same session would allow one person to follow along with another person working on a server.

As for usage, just enter the command screen.  This will start up a screen session for you to work in.  In order to detach from the current screen session you are working in just do ctrl+a and then d.  The key combination of ctrl+a is used to indicate that the next action is for the window manager not screen(d is then used to detach).  An alternative way to detach the current screen you are working on is running the command screen -d.

Using Screen

Get a screen list:

screen -list

You will then see something like this:

There is a screen on:
26091.ttyp0.host        (Attached)
1 Socket in /tmp/screens/S-root.

This shows you the currently running screens. As you can see by the “(Attached)” bit, 26091 is currently attached. So since this screen is currently attached, you can remotey detach it with this command:

screen -d 26091

Or if you’re in the screen you want to detach currently, just run this:

screen -d

Now to reattach to that screen, run this command:

screen -r 26091

Or to Reattach the screen and if necessary detach it first:

screen -d -r 26091

In the above examples you obviously must replace 26091 with the actual number of the screen session.

To create a new screen session called LW, enter this:

screen -S LW

Setting up screen to all multiple users to connect to the same session

Multi-user is not on by default in screen for security reasons.  So in order to allow multiple users to connect to the same screen session, multi-user must be turned on.  Below are the steps needed to do this.

  1. Start with logging in and starting screen on the command line.
  2. Then type Ctrl-a to enter the command mode,
  3. Next type : (this is a colon) to enter the screen’s built-in command line.
  4. You can now activate the multi-user mode by entering multi-user on in the screen’s command line that appears in reverse color at the bottom of the console window.
  5. To execute, hit Return.

Now all that needs to be done is have the other person log in with the same user, type screen -x to connect to your screen session running in multi-user mode and follow what you do.


Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434

Avatar for J. Mays

About the Author: J. Mays

As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you'll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!

Latest Articles

How to install Redis on Linux (AlmaLinux)

Read Article

How to use NextCloud — setup and features

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article