man screen
:
Screen is a full-screen window manager that multiplexes a physical ter‐
minal between several processes (typically interactive shells). Each
virtual terminal provides the functions of a DEC VT100 terminal and, in
addition, several control functions from the ISO 6429 (ECMA 48, ANSI
X3.64) and ISO 2022 standards (e.g. insert/delete line and support for
multiple character sets). There is a scrollback history buffer for
each virtual terminal and a copy-and-paste mechanism that allows moving
text regions between windows.
When screen is called, it creates a single window with a shell in it
(or the specified command) and then gets out of your way so that you
can use the program as you normally would. Then, at any time, you can
create new (full-screen) windows with other programs in them (including
more shells), kill existing windows, view a list of windows, turn out‐
put logging on and off, copy-and-paste text between windows, view the
scrollback history, switch between windows in whatever manner you wish,
etc. All windows run their programs completely independent of each
other. Programs continue to run when their window is currently not vis‐
ible and even when the whole screen session is detached from the user's
terminal. When a program terminates, screen (per default) kills the
window that contained it. If this window was in the foreground, the
display switches to the previous window; if none are left, screen
exits.
With the technical explanation out of the way, how does it differ from say, creating tabs in a regular gnome terminal?
For the list of things you can do from the manual, I can already create new tabs, kill tabs, view a list of my tabs, switch between windows. Is it just more convenient with screen? Could someone explain in layman's terms the benefits?
Right out of the man page you C&P'd:
Simply put, when your internet connection blows up your
screen
'd programs keep running, and when you log back in you can re-attach to that session.Among other times where this might be useful are times where you would use
nohup
, e.g. running a script that can break network connectivity for a few seconds (having your session die and your script go away fromSIGHUP
can leave you with your machine off the network).I don't know many people who use the "screen management" features of screen, but I know lots of people who detach programs to keep them running after they log out.
If you know how works microsoft remote desktop, you easily understand how screen works. Mostly same except text-console only. So you could detach (disconnect) from screen console, and later reconnect to leaved session. Use hot-keys to switch between windows in screen, copy, paste, freeze, kill and so on.
So main benefit, is save you state of console if you suddenly disconnected from host where screen is initialised, so you could reconnect back to the host and re-attach last time session.
screen -Dr (disconnect if connected anyone else and connect to the session) C-a a C-a space C-a backspace For window rotate C-a c # to create new windows read man for more, but this one are most usefull hot-keys
For
SSH
sessions, it's a godsend. Instead of having 5 concurrent sessions (i.e., TCP connections) for tab functionality on a remote server, you can have 1.Now, imagine if you had to administer 5 different servers with 5 tabs on each. You would have 25 separate tabs. With this you can just have 5 tabs, and then you know which server you're on.
Another huge benefit is that you can log off (in this case, close the tab) from the TTY and then reconnect later and still have your session. This is extremely helpful for administering servers as well as at home if you just want to bring up a session later but don't want to keep looking at it for hours while working on other stuff.
I have also used screen to do a "Screen Sharing" session to my team members, showing a demo or showing how something works.
With screen you can have multiple users "see" and "work" on the same console. Useful for a demo or KT..
How-to: http://ubuntuforums.org/showthread.php?t=299286
With screen you can re-attach to a screen session from another pc or after you have restarted your pc. You can leave running an ssh session on a server without leave your terminal open.
Did you know what you can even create split windows with screen ?
There is also a patch to split windows vertically, but it is not a default setup.
I find this very useful, when I have to tail logs and startup apps (like tomcat) at same time ...