GNU Screen - multiplexes a physical terminal between several processes
- Apr 19, 2022
- 3 min read
What is GNU Screen ?
Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session.
More details can be found here https://www.gnu.org/software/screen/ if you work on a terminal session while using Screen, once you’re finished with your work and turn off the computer, it will save at that point.
Install Linux GNU Screen
If you're using Debian, Ubuntu or Linux Mint, you can execute the following command :
sudo apt-get updatesudo apt-get install screenIf you're using CentOS, you can install by :
sudo yum install screen or
yum install screen as root user.
Now, we're can verify that Screen is installed at machine, check it by :
screen --versionOutput
Screen version 4.06.02 (GNU) 23-Oct-17if you've that, you can finally use Screen
Starting Screen
To run Linux screen, we just have to type the word in our terminal session :
screen 
This will open a screen session, then hit "space" for the first time, then it creates a new window and start a shell in that window and mainly interact by combine "Ctrl+a".
You can get a list of commands by typing inside a screen session :
Ctrl+a ?Starting Named session
Name sessions are useful to help you manage your workflow when you run multiple screen sessions. To create a named session, run the command line below:
screen -S session_namein here, i create two sessions ( test1, test2 )
screen -S test1
screen -S test2then list all screen sessions by :
screen -ls
Managing windows inside Screen sessions
After creating two "test" sessions, we can jump into session by :
screen -r [processid] or [name of process]so it could be :
screen -r 24286
or
screen -r test2 inside test2 screen session, if you list screen session, you could see that test2 screen session on "Attached" mode while test1 "Detached". You're on test2 session at the moment

Inside each sessions, we can create multiple window and interact with them by some most common commands for managing Linux Screen Windows:
Ctrl+a c Create a new window (with shell).
Ctrl+a w List all windows.
Ctrl+a 0 Switch to window 0 (by number) or Ctrl+a " then type number.
Ctrl+a Shift+a Rename the current window.
Ctrl+a Shift+q Close all regions but the current one.
Ctrl+a Shift+x Close the current region.
Ctrl+a x Lock the current region.
Ctrl+a Ctrl+a Toggle between the current and previous windows
You can detach from the screen session at any time by typing:
Ctrl+a dBasic Screen session usage
I created three different windows, which handle 3 tasks by Ctrl+a c (three times), checking that all windows currently open in session by Ctrl+a w
You could see a mini pop up appears at bottom left of window display number of window with name respectively ( a default "bash" named when you create a new window )

If you wish to rename for the current window, type Ctrl+a Shift+a (Ctrl+a then Shift+a)
Set window's title to: set name herein this case:
window 0: top
window 1: disk
window2: cowsay ( window i want to use funny command which make cow "say" what you want to display on terminal )
so you just need to move to each window by Ctrl+a Ctrl+a then rename it.

After renaming you could see the list name of window changed
Now, easily to switch to each window by Ctrl+a 0/1/2 respect to which window you want to.
You can lock your current window by Ctrl+a x, using your current Ubuntu's user to unlock
Screen used by riottecboi <riottecboi> on ThinkPad-E590.
Password:Finally, when you're done with a certain session, you can type exit to close current session which you're in or kill by Sigterm from Linux
Conclusion
In this tutorial, i showed you how to use GNU Screen and make your work more efficient. Hope you like this, nice day !!!


Comments