GNU screen Kung Foo 
I've noticed that many people don't know GNU screen, eventhough it comes by default in almost every *nix OS - this includes linux, BSD, the new Mac OS, Solaris,etc. Latelly screen has been incredibly usefull for me while doing some remote administration jobs for
feax.net.
But what is screen? Reading screen's man page, you can find the following
Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).
In a simpler, way imagine those multiple desktops environments you have in X11 (or even under Windows or Mac OS, although they are not so common) where you can add or delete virtual desktops and switch between them, screen is the same thing but for terminals.
Why not open multiple terminals? Well because it can get a real mess! Believe me, I have dual display and I still remember that before using screen I had so many xterms that it seemed that I had black
post-its in my display.
Besides, if you are working on a remote machine it's better to have only one ssh connection and spawn 20 terminals within screen, instead of having 20 connections to the remote host.
I'm sure that with the last explanation there are probably some users that are not really convinced about screen, but let me tell you about another killer feature. Screen allows you to dettach terminals, in other words, it can make things go into background, without loosing any of their output, and they'll be there until you reattach it. So if you're in a remote shell, you can always dettach your
wget process and logout.
Last but not least, screen allows you to have, in a single window, multiple terminals, it gets really handy when you need to be copying stuff from one file to another.
Anyway I leave you some hints so you can start discovering the world of screen.
While in a shell type
screen, it will seem that nothing was done, but a new screen was initiated, now you can split your screen, add more screen, switch between screens, etc.
You can now use the following commands:
| Keys | Command | |
|---|
| Ctrl-a + c | create a new window with a shell | |
| Ctrl-a + n | next window | |
| Ctrl-a + p | previous window | |
| Ctrl-a + k | kill current window | |
| Ctrl-a + " | Shows a list with all the windows, from where you can select one | |
| Ctrl-a + N | Switchs to window N, where N is a number from 0 to the number of windows you have | |
| Ctrl-a + d | Dettach screen | |
| Ctrl-a + S | Splits current window into two | |
| Ctrl-a + TAB | Switchs between splitted parts | |
| Ctrl-a + _ | Monitors for silence | |
| Ctrl-a + M | Monitors for activity | |
Somes notes about the commands:
- When you split a window the new part will have no shell spawn into it, when you switch to that part just use Ctrl-a + n or Ctrl-a + " to select the window you want there.
- After you dettach the screen, you're back to your normal shell, there are two basic commands you have to keep in mind:
- screen -list which will list the screens that are running and in what pts they are running
- screen -x PTS reattach reattachs screen that is running in the pts PTS
- The last two commands, the monitoring commands, are a state of art in productivity improvement. Instead of regularly checking background windows if a compilation has ended or a program is spitting it's output you enable, respectivily, the silence monitor or the activity monitor and you'll be alerted automatically for such events.