This post is not only SSH related, but it can be very nicely utilized while working with the local terminal. It is good when you're on Windows host with Putty and don't want to create enormous amount of windows. Also this is very useful, if you don't want to keep your ssh session open while a big chunk of job is being executed.
Here is a picture of my screen session:
Some points to pay attention to:
The very last line belongs to screen. It says I have 5 sessions (or tabs, or windows, pick your name).
|users:1(5)||1 user with 5 open sessions|
|uptime:2.0||2 days of uptime|
|Mon, 08/30||date and time (truncated because of the size of the window)|
All what you see on the last line is configurable and can be set to show different values. Say, for example, you might want to see your wifi status, or the CPU temperature.
All you need to do to get this is to install screen, and insert this into your ~/.screenrc
Visible stuff is configured on lines 71-76 (sessions and their names which are created when screen start up) and lines 21-32 (counters, date time, etc.) I'm not going to elaborate on what every line does. The most interesting to tune, however, is backticks. It's obvious what it does from the documentation. Also, if you have any questions, don't hesitate to ask, I will do my best to answer everything.
Line #32 outputs a caption screen where user-defined backticks appear as a number between % and `, i.e "%6`"
The command below starts screen:
screen -dRRwhich detaches screen session from wherever it was last opened from and attaches to it. If no screen session has been opened, a new one is created. Check man screen for a list of options, but that one above is the best I've found so far.
Here is a list of commands and shortcuts to use with the configuration above:
|Command / Shortcut||Meaning|
|screen -dRR||Detaches existing screen session and attaches to it or starts a new session|
|<Ctrl+O><Ctrl+]>||Paste screen selection|
|<Ctrl+O><Ctrl+X>||Close split window|
|F5||Cycle through split windows|
One big plus of "ssh through screen" over "ssh without screen" is that you may start a job which takes hours to execute and then you can close your ssh client without worrying that the job will terminate and your session will end, because it won't. When you feel like you want to check how it goes, you just connect from the same place, or a different one, it doesn't matter, and attach to the existing screen session - that simple. If you are in the middle of something and you have a lot of stuff open, but you have to go right now and you don't want to close everything. It's all right, you don't have to, just close your ssh session. Next time, reattach to the screen with "screen -dRR" - done - everything is where you have left it.
BackticksI publish all of my backticks with a right free to use, but without any warranties. References are appreciated.