What is Screen in Linux and how to use it?
Ever stuck in long running process in Linux terminal or connection dropped and you have to restart your work again. Well, Screen helps you to overcome this issue.
Screen is a terminal multiplexer which means you can open any number of windows (virtual terminal) inside of a terminal. Screen helps to run your process in the server, even if you get disconnected.
Installation of GNU Linux
- Install in Ubuntu and Debian
$ sudo apt update
$ sudo apt install screen
- Install in CentOS and Fedora
$ sudo yum install screen
Starting Screen in Linux
To start the screen session, simply type screen in your console/terminal.
This will open a new session and create a window, and start the shell in that window.
To check out the list of commands that you can perform in screen.
$ ctrl +a ?
Below are some most common commands for managing Linux Screen Windows:
• Ctrl+a c Create a new window (with shell).
• Ctrl+a “ List all windows.
• Ctrl+a 0 Switch to window 0 (by number).
• Ctrl+a A Rename the current window.
• Ctrl+a S Split current region horizontally into two regions.
• Ctrl+a | 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 Close all regions but the current one.
• Ctrl+a X Close the current region.
Detach and Reattached to Linux screen
$ screen -r
To list the screen windows
$ screen -ls