Atlantic.Net Blog

How to Install and Use the Screen Command on Ubuntu

Screen is a console application that allows users to open several separate terminal instances within a single terminal. It is very useful when you are performing a long-running task on a remote system and you lose your connection or SSH session. In this case, the Screen command utility will help you to resume the SSH session. The process running in the Screen will continue running even after closing the terminal windows. You can reconnect exactly from where the session was disconnected.

In this post, we will show you how to install and use the Screen command on Ubuntu 20.04.

Install Screen

By default, the Screen package is included in the Ubuntu 20.04 default repository. You can install it with the following command:

apt-get update -y
apt-get install screen -y

Once the Screen package is installed, verify the installed version of Screen using the following command:

screen --version

Output:

Screen version 4.08.00 (GNU) 05-Feb-20

To print the list of all options, press CTRL+a followed by ?:

How to Use the Screen Command

To create a new name session, run the following command:

screen -S name1

To exit from the screen session, run the following command:

exit

To create a new screen window, press CTRL+a followed by c:

To list all open windows, press CTRL+a followed by :

To change the current window to 0, press CTRL+a followed by 0.

To rename the current windows, press CTRL+a followed by A.

To split the screen horizontally, press CTRL+a followed by S.

To toggle between the split windows, press CTRL+a followed by tab.

To split the screen vertically, press CTRL+a followed by |.

When you have finished and you want to quit the screen session, you can use the command CTRL+a followed by k.

To detach from the screen session, press CTRL+a followed by d.

To find the session id of all screen sessions, run the following command:

screen -ls

You should see the following output:

There are screens on:
	23829.name1	(04/18/2021 09:19:50 AM)	(Detached)
	23751.name1	(04/18/2021 09:09:01 AM)	(Attached)
	23724.pts-0.ubuntu2004	(04/18/2021 09:04:05 AM)	(Detached)
	23670.pts-0.ubuntu2004	(04/18/2021 09:02:42 AM)	(Detached)
4 Sockets in /run/screen/S-root.

To resume your screen session named 23829.name1, run the following command:

screen -r 23829.name1

Conclusion

In the above guide, you learned how to use Screen command-line utility to open multiple screens from a single session, switch between them, resume, detach and resume the screen session. You can use the command on your Atlantic.Net VPS remote system.

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year