This blog has moved! Redirecting...
You should be automatically redirected. If not, visit http://scrolls.mafgani.net/ and update your bookmarks.

Thursday, March 08, 2007

Using screen

My God! I can't believe I didn't put more effort into looking into screen earlier. This is such a wonderful utility. Just imagine ssh-ing to a machine and having your work go on even if you face a network disconnection. Wonderful stuff!
To start a screen, type "screen" at the prompt.
You have now opened a screen. It can support multiple windows. So if you have multiple tasks, you need not open many different terminals. Try it out. Run top in the current screen. Now, open a new window by the key sequence "ctrl-a" "c". Each window can support a task as a normal shell would. To scroll through the windows, use "ctrl-a" "p" for the previous window or "ctrl-a" "n" for the next one. If you go back to the first window, you'll see top still running.
If you desire, you can also open several screens. In case you have ssh-ed to a machine and you'd like to log out but still keep your process running, you need to detach the screen before logging out. In order to detach a screen, use the key sequence "ctrl-a" "d". You will now be returned to the shell. To see the status of all the screens, do "screen -ls". The output looks something like:

[silverstreak@silverstreak Desktop]$ screen -ls
There are screens on:
22077.pts-0.silverstreak (Detached)
22153.pts-0.silverstreak (Detached)
2 Sockets in /var/run/screen/S-silverstreak.

Since both screens are detached, it's ok to log off without losing any work. When you log back on, the screens will still remain detached. In order to re-attach a screen (let's say we want to re-attach the first one in the list), do "screen -r 22077.pts-0.silverstreak". Very simple and very handy!

Labels:

0 Comments:

Post a Comment

<< Home