When working on the terminal either locally or via ssh, many times it is needed to open an additional terminal while a process is already running on the first one. For example, you are downloading a huge file and it needs 40mins or more to finish and you want to do something else on a new terminal while you are downloading the file. There is a really handy tool in Linux called “screen” that can help overcome the limitation especially if your working through ssh and don’t want to open multiple ssh sessions. You can have multiple screens, each one of them running independently and you can switch between them using keyboard shortcuts!
Try running on your terminal screen --version
to check if it is already installed.
If not you can sudo apt install screen
or sudo yum install screen
After you install it you can run screen
in order to start the tool. Once you run screen you will create a new session and a blank screen will open. You can have a session with multiple screens and you can have also multiple sessions. A session can be detached and reattached when needed. You can have a screen session running even if you disconnect from your ssh session and reattach to it later on.
If you run screen -S mysession
you will create a session named “mysession” (which makes it easier to recognize it later on when needed. You can detach from a session with Ctrl+a
d
. You can type screen -ls
in order to list all the sessions you have(you can see the session id here). You can reattach to a session by typing screen -r
followed by the session id or session name.
A session is killed once all the screens inside that session are closed.
Once you create a session you can try the following commands-shortcuts:
(first, type CTRL+a and then release and type the next character)
Ctrl+a
c
Create a new window (shell) Ctrl+a
"
List all windowsCtrl+a
0
Switch to window 0 (can be 0-9 )Ctrl+a
A
Rename the current windowCtrl+a
S
Split current region horizontally into two regionsCtrl+a
|
Split current region vertically into two regionsCtrl+a
tab
Switch the input focus to the next regionCtrl+a
Ctrl+a
Toggle between the current and previous regionCtrl+a
Q
Close all regions but the current oneCtrl+a
X
Close the current regionHappy screening!
Extra functionality of SCREEN
Like other linux applications you can edit the configuration of the screen by editing either the users config file or the system-wide config file:sudo vim /etc/screenrc
or
sudo vim ~/.screenrc
A great function to log screen and trace activity.Ctr+a
H
Amazing functionality to get alert when there is a change in one of the screens. Very useful if for example you are downloading a big file and you move on to another screen and want to get an alert when the file while finish downloading.Ctrl+a
M
will monitor for an activity or an output in the screenCtrl+A
_
will monitor for the inactivity of the screen (downloading big file)
Introduction In a shocking revelation, it has been disclosed that the infrastructure used to maintain…
Introduction: In the early hours of January 5, the cryptocurrency community was abuzz with speculation…
Summary: A newly identified technique called SMTP smuggling poses a significant threat to email security…
Since 2019, the Operation Triangulation spyware has targeted iPhone devices, exploiting undocumented features within Apple…
The Challenge: CVE-2023-38545 In the world of digital security, a formidable adversary has emerged -…
Alert: Safeguard Your Confluence for an Urgent Upgrade! Advisory Release Date: Wednesday, Oct 4th, 2023,…
This website uses cookies.