On UNIX, GNU Screen is a utility that i cannot live without. I know many console users share the same point of view with me.
What is GNU Screen? it is a terminal multiplexer and you can run multiple console-based applications simultaneously.
The best part of it is that you can leave it running on remote machines and come back to pick up your console sessions.
It’s like VNC or Remote Desktop but for UNIX console. As you know that on UNIX if you run something on a shell and you got disconnected from it then your sessions will also stop. All work will be gone.
With that feature GNU Screen is indispensable when it comes to do console sessions on low speed connection. If you got disconnected then all you have to do is reconnect and continue with your work. Or if you do something that takes a long time to finish, say maybe archiving and backing up many files, then simply launch it from GNU Screen session then detach from it and disconnect. Later on you can come back and reattach again to check the progress.
Anyway, here are some most useful features of GNU Screen that i use most of the time.
|Commands||What It Does|
|Ctrl-a ? (question mark)||man” and “info” is your friend. By typing “man screen” and “info screen” you’ll get a lot of informations regarding Screen.|
|Ctrl-a d||screen -r” to resume the session. If there are several Screen sessions running then add the session ID to the end of it. Ex: “screen -r 1088“. What really nice is that means you can login from anywhere to start your Screen session then later on continue the session again from different place.|
|Ctrl-a c||Create a new window. By default it creates a new shell instance according your system setup (usually 90% of the time this is either bash or tcsh).|
|Ctrl-a A (capital A)|
|Ctrl-a ” (double quote)|
|Ctrl-a n, Ctrl-a p||If you have multiple windows running then this command will do the flipping between the next window (using “Ctrl-a n”) and the previous window (using “Ctrl-a p”).|
|Ctrl-a ESC, Ctrl-a ]|| |
In copy buffer mode you can move the cursor freely using directional keys. In this example i’m “cat”-ing the content of the Message of the Day (/etc/motd) in my Ubuntu machine. Next step is to highlight the block that you want to copy to the buffer. Move your cursor to the beginning of the block that you want to copy then press enter. That will mark the start point of the block.
Then move your cursor toward the end of the block that you want to copy (see image B). In this example i’m copying the text “System Information …” from Ubuntu’s MOTD
Press enter again to copy the highlighted block into the buffer. This will end the “Copy Mode” and put you back to the active screen. You can tell when it says “Copied # characters into buffer” (see image C)
Use “Ctrl-a ]” to paste whatever is in the buffer (see image D). As you can see i’m pasting the text “System Information …” from the Screen’s copy buffer.