Command Line Tools: Using GNU Screen
posted: February 7th, 2007
What is screen? GNU Screen is a free terminal multiplexer. Now, we can move
on to the good stuff.
I have been doing a lot of work for this website on a laptop. My laptop has
a small viewable screen; 14.1 inches to be exact. I am not complaining about
my lack of screen size, but I do recognize the importance of what is on my screen
at a given time.
An application that cuts down on the clutter on my screen is screen. Sorry,
I was trying to be funny there. Here are a few uses of screen that may change
the way you use your shell accounts.
The most important command is this:
which screen
If you see something like the following, you are in business:
/usr/bin/screen
If you do not see any results, you can visit the GNU page for screen.
The directions on this page will get you to download, compile, and install the
source code on to your Unix-like machine. This is where it can get really complicated
really fast. If you are using a Linux Distribution (i.e. Gentoo, Redhat, or
Ubuntu), there is probably a screen package available for you to install. I
will not tell you how to install screen in this article, but I will say it is
probably not hard. If you have any questions about a specific distribution installation,
I can point you in the right direction. Since that is out of the way, let`s
get into using screen.
First to use screen, we need to start it. This is simple. Type the following.
screen
I know, super tough huh? Now that we have screen running, we can start using
some of screen`s feature. Next, we can create a new screen window.
control+a c
This means press and hold the "control" button and then press "a".
Release both "control" and "a". Then you press the "c"
button. Typing this maybe a little weird for you, but after a while you will
get use to it. You may say wow, it did not do anything. Actually it did do something.
You now have two shells, if you do not believe me, type:
ls
Now that you have something on your screen; use the next window command.
control+a n
Now you should see a prompt again. Try the next window command a few times.
You are logged in once, but you can work independently on two difference tasks.
If you use Putty to connect to a Unix-like system you can save yourself an extra
login with using screen. Just as you can go to the next window, you can go to
the previous one also. The previous window command is:
control+a p
Screen is useful for running tasks that will take a long period of time to
finish. You may want to log out and still have your task run. Screen handles
these two problems with ease. To log out and still have screen running you have
to detach the screen process. You can detach and reattach to a screen process
with the following commands:
screen -d
screen -r
You can list your screen sessions with:
screen -ls
I decided to write up this small tutorial because I recently showed someone
screen and he liked it. I thought maybe I should share it with more people.
This is only the surface of screen's capabilities. Another useful command
is:
man screen
This will show you screen's manual; giving you all of the commands to use screen
to it's full capability. Until next time, see you later.