How to Use Screen in Linux

How to Use Screen in Linux

5 Comments on How to Use Screen in Linux

Screen provides virtual terminals that can continue running even when the the user has logged off or disconnected from the session. New sessions can be created at any time and can have different programs running in them.

Installing Screen
Screen is installed by default in Ubuntu Linux and other Linux distributions. The source code for screen can be downloaded from the GNU website.

Using Screen
Screen can be started by running the command:


Session names can be added to the screen sessions to make it easier to reattach later with the -S option:

screen -S mysql

A list of screen session that have been created can be displayed by using the -ls option:

bill@K11:~$ screen -ls
There is a screen on:
        17260.mysql     (30/08/11 16:19:57)     (Detached)
1 Socket in /var/run/screen/S-bill.

A session can be reattached if it is not attached. To reattach a screen session, the screen command is used with the -R option to reattach the last detached session or the -r option with the process id or name the session was given:

screen -r mysql

There are commands that can be used from with in screen:

Key Action
Ctrl+a c New screen session.
Ctrl+a n Next screen session.
Ctrl+a p Previous screen session.
Ctrl+a “ Select a screen session from a list.
Ctrl+a Ctrl+a Previously viewed screen session.
Ctrl+a S Split screen into horizontal regions.
Ctrl+a | Split screen into vertical regions.
Ctrl+a :resize Resize regions.
Ctrl+a :fit Fit screen to new terminal size.
Ctrl+a tab Switch to next screen session.
Ctrl+a d Detach from session.
Ctrl+a A Set a window title.
Ctrl+a x Lock screen session with a password.
Ctrl+a [ Scroll and copy mode.
Ctrl+a ] Paste the buffer.
Ctrl+a > Write the paste buffer to a file.
Ctrl+a < Read a file to the paste buffer.
Ctrl ? Show screen help.
Ctrl : Screen command prompt.

A screen session can end with the following command:


Sessions can be detached and resumed later either pressing Ctrl+a then d or just closing the window if in a graphical user interface.

More information can be found on screen at Screen User’s Manualor by using the following command:

man screen

About the author:

Bill Payne started working as a paid professional software developer at the young age of 12 years old developing simple games and other applications for pre-packaged computers. Bill has since developed software for many industries such as direct sales and the the stock market. Bill has now started sharing his many years of software development experience through a blog on the MPSHouse website and one on one lessons.


  1. rot10clean  - 30 August , 2011 - 8:31 pm
    Reply /

    Might be awesome to allow X to run from screen if not X not previously started….troubles getting this useful feature going 🙁

    • Rob  - 30 August , 2011 - 9:40 pm
      Reply /

      why would you want to run X in screen? just run X then run a terminal. :mrgreen:

  2. Arun Chandrasekaran  - 31 August , 2011 - 3:46 am
    Reply /

    What GNU screen lacks is the vertical split, which is available as an un official patch.

  3. How to Use Screen in Linux | Linux | Syngu  - 31 August , 2011 - 5:41 am
    Reply /

    […] session. New sessions can be created at any time and can have different programs running in them. Read more… Categories: Linux     Share | Related […]

Leave a comment

Back to Top