The screen command usages and examples – Unix/Linux

By -

The screen command under the Unix is used to execute some process under or inside a screen. That means you can simply detach from the screen and keep working on that server. It is normally very helpful when you need to install some time consuming applications on the server. In this case, you can execute that installation on a screen. Then you may detach from screen, but the process is still running on that screen. After sometime you can re-attach that screen and control that process.

Here, I am explaining some common screen command usages and examples:

The command “screen“;
The command “screen” simply open a screen window for your process. You can execute the command over here and may detach from there.

Usage:

screen

Use Ctrl + AD(press CTRL+A followed by d) to detach from screen.

Or, you may open the screen with your process itself.
Example:

screen top

top

In this example, the top command will execute under the screen [Screen0].

Other important switches;
To view the screen

screen -x

Example:

root@jishnu [~]# screen -x
There are several suitable screens on:
        2294.pts-0.jishnu       (Detached)
        19946.pts-0.jishnu      (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

Usage:

root@jishnu [~]# screen -x 19946.pts-0.jishnu

List all screens;

screen -ls

Example:

root@jishnu [~]#  screen -ls
There are screens on:
        2294.pts-0.jishnu       (Detached)
        19993.pts-0.jishnu      (Detached)
2 Sockets in /var/run/screen/S-root.

To attach to a running session;

screen -r

Example:

root@jishnu [~]# screen -r 19946.pts-0.jishnu

That’s it :-)

Related:
groupdel, groupmems, groupmod, useradd , usermod , chgrp, chown, ls, head, tail, top, ps, find, crontabftp commands, tar, rpm, rkhunter, Rsync, grep, netstat command switches, netstat command’s practical usages, OpenVZ commands, lsof command

Linux Server Admin, Infopark, Cochin, Kerala. Contact me : arun(at)crybit.com

2 Comments to The screen command usages and examples – Unix/Linux

  1. Thank arun # screen top shows the running screens on the server am i right?, other way i real love this

    Thank u

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *