Have you ever ever confronted the scenario the place you carry out a long-running job on a distant machine, and instantly your connection drops, the SSH session is terminated, and your work is misplaced. Effectively, it has occurred to all of us in some unspecified time in the future, hasn’t it? Fortunately, there’s a utility known as screen
that enables us to renew the classes.
Screen or GNU screen is a terminal multiplexer. In different phrases, it means you can begin a screen session after which open any variety of home windows (digital terminals) inside that session. Processes operating in screen will proceed to run when their window just isn’t seen even in case you get disconnected.
Set up Linux GNU screen
The screen package deal is pre-installed on most Linux distros these days. You possibly can verify whether it is put in in your system by typing:
$ screen --version
Output:
Screen version 4.06.02 (GNU) 23-Oct-17
Should you don’t have screen put in in your system, you possibly can simply set up it utilizing the package deal supervisor of your distro.
Set up Linux screen on Ubuntu and Debian
$ sudo apt update
$ sudo apt install screen
Set up Linux screen on CentOS and Fedora
$ sudo yum install screen
Beginning Linux screen
To start out a screen session, merely sort screen
in your console:
$ screen
It will open a screen session, create a brand new window, and begin a shell in that window.
Now that you’ve opened a screen session, you may get a listing of instructions by typing:
Ctrl+a ?
Beginning Named Session
Named classes are helpful once you run a number of screen classes. To create a named session, run the screen command with the next arguments:
$ screen -S session_name
It’s all the time a good suggestion to decide on a descriptive session identify.
Working with Linux screen Home windows
Whenever you begin a brand new screen session, it creates a single window with a shell in it.
You possibly can have a number of home windows inside a screen session.
To create a brand new window with shell sort Ctrl+a
c
, the primary obtainable quantity from the vary 0...9
shall be assigned to it.
Beneath are some most typical instructions for managing Linux screen Home windows:
Ctrl+a
c
Create a brand new window (with shell)Ctrl+a
"
Checklist all windowCtrl+a
0
Swap to window 0 (by quantity )Ctrl+a
A
Rename the present windowCtrl+a
S
Break up present area horizontally into two areasCtrl+a
|
Break up present area vertically into two areasCtrl+a
tab
Swap the enter focus to the subsequent areaCtrl+a
Ctrl+a
Toggle between the present and former areaCtrl+a
Q
Shut all areas however the present oneCtrl+a
X
Shut the present area
Detach from Linux Screen Session
You possibly can detach from the screen session at any time by typing:
Ctrl+a
d
This system operating within the screen session will proceed to run after you detach from the session.
Reattach to a Linux Screen
To renew your screen session use the next command:
$ screen -r
In case you may have a number of screen classes operating in your machine, you will have to append the screen session ID after the r
change.
To seek out the session ID checklist the present operating screen classes with:
$ screen -ls
Output:
There are screens on:
12845.pts-0.linuxconcept-desktop (Detached)
12466.pts-0.linuxconcept-desktop (Detached)
2 Sockets in /run/screens/S-linuxconcept.
If you wish to restore screen 12466.pts-0, then sort the next command:
$ screen -r 12466
Customise Linux Screen
When screen
is began, it reads its configuration parameters from /etc/screenrc
and ~/.screenrc
if the file is current. We are able to modify the default screen settings in line with our preferences utilizing the .screenrc
file.
Here’s a pattern ~/.screenrc
configuration with custom-made standing line and few extra choices:
~/.screenrc
# Turn off the welcome message
startup_message off
# Disable visual bell
vbell off
# Set scrollback buffer to 10000
defscrollback 10000
# Customize the status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
Primary Linux Screen Utilization
Beneath are essentially the most primary steps for getting began with screen:
- On the command immediate, sort
screen
. - Run the specified program.
- Use the important thing sequence
Ctrl-a
+Ctrl-d
to detach from the screen session. - Reattach to the screen session by typing
screen -r
.
Conclusion
n this tutorial, you realized how one can use Gnu screen. Now you can begin utilizing the screen utility and create a number of screen home windows from a single session, navigate between home windows, detach and resume screen classes and personalize your screen terminal utilizing the .screenrc
file.
There’s tons extra to find out about Gnu screen at Screen User’s Manual web page.
In case you have any questions or suggestions, be at liberty to go away a remark.
0 Comments