Screen

From Silenceisdefeat

Jump to: navigation, search

GNU Screen
"Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells.", quoth http://www.gnu.org/software/screen/


So. why should you use such a - seemingly - complicated program?
How many times have you been logged into silenceisdefeat, running irssi or compiling some stuff and *boom* your connection was cut, due to a 24h reconnect or a blackout? As a "lost terminal" kills every running process on this terminal it might be a bit or very annoying, depending on the things one was doing. And exactly this is where "screen" comes very handy.
If you run screen it creates a virtual terminal inside your actual (ssh) terminal which keeps running, even if you - or some circumstances - kill your ssh session. When you reconnect you can simply open your screen again and continue your work.


Screen's tools of trade
If you want to create a new screen session simply run "screen" in your ssh session. This will open screen and give you some legal information as well as the version of screen and invite you to press [SPACE] or [RETURN] to enter the shell.
Now you have a first stable and 24/7 opened shell on silenceisdefeat.
Ist almost certain that you do not want only one stable shell on sd, but more. That's no problem for screen either. Just hit the Ctrl+A c to create a new shell inside screen. That's it.
Now there's only one problem: How to get back to your former shell?
Hit Ctrl+A " to get a list of all your opened up shells inside screen, then choose one and hit [ENTER].
Another way of changing your shells is to hit Ctrl+A 0...9, which spares you selecting the shell you want, if you know the number it is assigned to.
If you just want to reopen the shell you used before switching to another and/or don't know the internal number, then you'll just need to hit Ctrl+A [BACKSPACE].
As the number of shells inside screen grows you will lose track of your shells and wonder where, e.g. irssi, is running. There's no problem, without a solution:
Inside a shell hit Ctrl+A A (captial A!) and screen will prompt you to change the shell's name - default is "bash" -, which will be shown in the shell overview and support you in working with screen.


What's next?
As you may have expected the commands shown above are just the tip of the iceberg.
If you want to learn more about the usage of screen and screen itself, don't hesitate to read screen's manpage.
You might as well consider reading the relevant article in the Gentoo Wiki, which even has pictures inside. ;)
http://gentoo-wiki.com/TIP_Using_screen

Personal tools