The 1st thing I would tell a junior engineer, learn how to use “screen”. It’s extremely important tool allowing us to run scripts or commands in their own virtual window within the terminal, essentially allowing us to have a terminal on multi-tasking environment where we can switch between windows or another users at will. These are useful features that may help you in your daily administration tasks.
- Use multiple shell windows from a single SSH session.
- Keep a shell active even through network disruptions.
- Disconnect and re-connect to a shell sessions from multiple locations.
- Run a long running process without maintaining an active shell session.
If you do not have screen, then you can install it easily from an RPM or the package file for your system. For example, on CentOS you can install screen with yum: yum install screen
Basic but useful command with Screen
List a particular users screen sessions:
screen -list username/
(it’s important to have forward slash)
List your own active screen sessions:
Re-attach to users screen and session:
screen -x username/shared-session
Start a screen session and give it a unique name:
screen -S desired name
Detach from a running screen session leaving it running in the background:
Hit the key combination: Control + A/a + D/d (not case sensitive)
Re-attach to a specific screen you’ve named:
screen -R "the screen name to be re-attached"
Power detach a screen that you are logged into from another location:
This is helpful if you’ve been accidentally disconnected from ssh while in a remote screen session and it’s still attached.
screen -D "the screen name to be detached"