Linux Screen is very powerful and allows you to do many things. Users can keep a shell active even if there’s a network disruption, use multiple shell window from one SSH session, run longer running processes without needing an active shell session and disconnect and re-connect from multiple locations to shell sessions.
Linux Screen Tips
There are several things you should know when using Linux Screen. Here are some of the top tips to help with your needs when it comes to using Screen.
How to Install Screen with Yum
You may already have screen on your system and it may just be a matter of finding it. With most CentOS and Red Hat distributions Linux Screen is found in /usr/bin/screen.
If you don’t already have screen, it can be installed from a package file or RPM for your specific system.
How to Start Linux Screen
You will need to use the command line:
| [root@office ~]# screen
This will get you inside a window within screen. Other than a few special characters, it will function just like a normal shell.
Using the Control Command
The control command is used by pressing ctrl-a. This is the control key and it will send a signal to Linux screen instead of the shell. If you press ctrl-a and then ? you will get a screen help page. This will display the keys you can use for different commands. These keys can be reconfigured to fit your liking through the .screenrc file.
How to Create Windows
Creating a new window is easy. Just press ctrl-a and then press c. This will give you a new window with a default prompt. The old window will remain active and you can switch back and forth between the two.
How to Switch Between Windows
Using the command ctrl-a and then pressing n will allow you to switch between windows. You will be able to move forward and back as the windows work like a carousel and will loop around. Each process will remain active until you actually kill the window. How to Detach from Screen The command ctrl-a and then d will allow you to detach from screen. This is the most powerful part of Linux Screen because you can detach from a window and reattach later. If you detach, it will drop you into the shell, while all the screen windows will still be there to reattach to later. Reattaching to Screen After a connection drops or you detach from screen, you can reattach with the command: | [user@office ~]$ screen -r you can specify the screen you want, as well. How to Log Screen Output The command ctrl-a and then H will allow you to create a running log of your session. The data will be appended through multiple sessions and you can capture what you have done. This is especially helpful if you make multiple changes. Alerts Linux Screen has the ability to monitor a window for inactivity and activity. This makes is great for downloading larger files or waiting for output. You can use ctrl-a and then M to look for activity when waiting for a long running program. This will give you an alert at the bottom of the page. It’s also possible to monitor for inactivity. This is often used when downloading a large file or compiling a program. You will receive a notice when there isn’t any more output. Locking your Screen Session If you need to lock your screen session to walk away for a minute, you can use ctrl-a and then x. This will make it so that you need a password to access the session again. How to Stop Screen When it’s time to stop screen, you can do this by typing exit from your shell. This will close the screen window. You will need to close all of your windows to terminate the entire session. The command ctrl-a and then k will also kill the screen. Use these tips to help make using Linux Screen even easier.