• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Use Linux Screen

Written by Admin, Updated On May 15, 2020
screen, terminal
How to Use Linux Screen

Using Screen or GNU screen you can start a screen session and open any number of virtual terminals inside a session. Processes under that screen will remains continue to run even if drops the connection.

Install Linux GNU Screen#

Currently, most Linux distributions have pre-installed the screen package. To check the whether it is installed or not, type:

screen --version
Screen version 4.06.02 (GNU) 23-Oct-17

If the screen is not installed on your system, you can installed easily.

Install Screen on Ubuntu and Debian#

sudo apt install screen

Install Screen on CentOS and Fedora#

sudo yum install screen

Starting Linux Screen#

Open your terminal and type screen to launch the screen:

screen

It will start a new window within the screen. To get the list of all commands type:

Ctrl+a ?

Starting Session with Name#

When have multiple sessions, it is difficult to find. We can create session by giving name which will be very useful to identify. To create a session with name, run following command:

screen -S session_name

Here, you should replace session_name with your appropriate name.

Linux Screen Windows#

When a new session started, it creates a single window with a shell in it. You can have multiple windows inside a Screen session.

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 Create a new windows.
  • Ctrl-a + w Displays the list of all currently opened windows .
  • Ctrl-a + A Rename the current window.
  • Ctrl-a + n Go to the next windows.
  • Ctrl-a + p Go to the previous windows.
  • Ctrl-a + Ctrl-a Toggle between current and last window.
  • Ctrl-a + k Close the current windows (kill).
  • Ctrl-a + S Split the current windows horizontally.
  • Ctrl-a + | It split the current windows vertically.
  • Ctrl-a + d Detach a screen session without stopping it.
  • Ctrl-a + r Reattach a detached screen session.
  • Ctrl-a + [ Start the copy mode.
  • Ctrl-a + ] Paste the copied text.

Detach from Screen Session#

To detach from the screen session at any time type:

Ctrl+a d

The running program in screen session will be continue to run even after you detach from the session.

Reattach to a Screen#

You can resume your screen session using the following command:

screen -r

Add the session id after the -r flag if you have multiple session started. Below is the example:

screen -r 11205

Here, 11205 is the session id. To get the list of session ID for current running screen type:

screen -ls
There are screens on:
11205.pts-0.tecnstuff-desktop (Detached)
11335.pts-0.tecnstuff-desktop (Detached)
11408.pts-0.tecnstuff-desktop (Detached)
3 Sockets in /run/screens/S-tecnstuff.

Conclusion#

In this tutorial, you learned how to use GNU Screen in Linux to resume the sessions even after disconnected. Now you can start use of the Screen utility to create multiple screen windows from a single session, detach and resume screen sessions.

To learn more about GNU Screen visit Screen User’s Manual page.

Feel free to leave a comment if you have any questions.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Use Linux SFTP Command to Transfer Files
Next Article   How to Use Linux FTP Command to Transfer Files

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Jenkins on Debian 11
    How to Install Jenkins on Debian 11 January 5, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook