How to install and Use Linux Screen

How to install and Use Linux Screen

In this post, we are going to show that how to Install and Use Screen in Linux including Ubuntu. If your are going to Install and use Screen on your Linux system then this post is ideal for you.

Screen or GNU Screen is a terminal multiplexer for Unix-like operating systems. With help of it, you can start a screen session and then open multiple windows (virtual terminals) within that session. It is an alternative to Tmux terminal multiplexer and very useful when you are running multiple command-line program at the same time.


How to Install and Use Linux Screen

At the present time, the Linux screen is pre-installed on most of Linux distribution. To check if it is installed or not in your system, run the command below:

screen --version
Output
Screen version 4.08.00 (GNU) 05-Feb-20

If screen is not installed on your linux system then follow below steps to install and use it on your Linux system:

Install Linux Screen on Ubuntu and Debian

sudo apt update
sudo apt install screen

Install Linux Screen on CentOS and Fedora 

sudo yum install screen

Started Linux screen

Run the screen command in your terminal to start a screen session:

Sudo screen

When you run the screen command, it will display a page of license information. Just press space button or enter button to end this page.

GNU Screen version 4.08.00 (GNU) 05-Feb-20

Copyright (c) 2018-2020 Alexander Naumov, Amadeusz Slawinski
Copyright (c) 2015-2017 Juergen Weigert, Alexander Naumov, Amadeusz Slawinski
Copyright (c) 2010-2014 Juergen Weigert, Sadrul Habib Chowdhury
Copyright (c) 2008-2009 Juergen Weigert, Michael Schroeder, Micah Cowan, Sadrul Habib Chowdhury
Copyright (c) 1993-2007 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see the file COPYING); if
not, see https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA  02111-1301  USA.

Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to screen-devel@gnu.org


Capabilities:
+copy +remote-detach +power-detach +multi-attach +multi-user +font +color-256 +utf8 +rxvt +builtin-telnet


                             [Press Space or Return to end.]

Now, a screen session opened and active. To get a list of all commands related to Linux screen, type following key combination: Ctrl+a ?

Output                     
                           Screen key bindings, page 1 of 2.
                           Command key:  ^A   Literal ^A:  a

break       ^B b       hardcopy    h          monitor     M          remove      X          version     v
clear       C          help        ?          next        ^@ ^N sp n removebuf   =          width       W
colon       :          history     { }        number      N          reset       Z          windows     ^W w
copy        ^[ [       info        i          only        Q          screen      ^C c       wrap        ^R r
detach      ^D d       kill        K k        other       ^A         select      '          writebuf    >
digraph     ^V         lastmsg     ^M m       pow_break   B          silence     _          xoff        ^S s
displays    *          license     ,          pow_detach  D          split       S          xon         ^Q q
dumptermcap .          lockscreen  ^X x       prev        ^H ^P p ^? suspend     ^Z z
fit         F          log         H          quit        \          time        ^T t
flow        ^F f       login       L          readbuf     <          title       A
focus       ^I         meta        a          redisplay   ^L l       vbell       ^G

^]   paste .
"    windowlist -b
-    select -
0    select 0
1    select 1
2    select 2
3    select 3
4    select 4
5    select 5
6    select 6
7    select 7

                      [Press Space for next page; Return to end.]

Create Linux Screen Session with Name

By default, when you create a screen session, it is named numerically. If you want to create a new session with the name, run the screen command as show below:

screen -S session_name

Replace session_name with your descriptive name.


Detach from Linux Screen Session

If you want to detach from the Screen session and want to return to main shell, type Ctrl+d .

It show a message similar like below:

[detached from 121.pts-0.LAPTOP-NPC03IHJ]

Re-attach to Screen Session

If you want to re-attach a Screen session, first you will need to find the ID of the tmux session using command below:

screen -ls
Output
There are several suitable screens on:
        121.pts-0.LAPTOP-NPC03IHJ       (05/12/21 17:30:17)     (Detached)
        87.pts-0.LAPTOP-NPC03IHJ        (05/12/21 17:13:18)     (Detached)
        53.pts-0.LAPTOP-NPC03IHJ        (05/12/21 17:07:44)     (Detached)
        28.pts-0.LAPTOP-NPC03IHJ        (05/12/21 17:03:46)     (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

The first column of the output is the ID of the session.

To re-attach to screen 87, run the command below:

screen -r 87

Linux screen Windows Management

Here, we are show some most common and useful commands for managing Screen windows and regions:

To create a new window with shell type Ctrl+a c, the first available number from the range 0...9 will be assigned to it.

Below are some most common commands for managing Linux Screen Windows:

  • Ctrl+a c – It is create a new window (with shell).
  • Ctrl+a " – it is display a list of all created windows.
  • Ctrl+a 0 – Switch between windows (by number ).
  • Ctrl+a A – It is rename the current window.
  • Ctrl+a S – Split current region horizontally into two regions.
  • Ctrl+a | – It is split current region vertically into two regions.
  • Ctrl+a tab – Switch the input focus to the next region.
  • Ctrl+a Ctrl+a – Toggle between the current and previous windows
  • Ctrl+a Q – It is close the all regions but the current one.
  • Ctrl+a X – Close the current region.

That’s all

If you find any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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.

Scroll to Top