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.
Use Ctrl + AD(press CTRL+A followed by d) to detach from screen.
Or, you may open the screen with your process itself.
In this example, the top command will execute under the screen [Screen0].
Other important switches;
To view the screen
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.
root@jishnu [~]# screen -x 19946.pts-0.jishnu
List all screens;
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;
root@jishnu [~]# screen -r 19946.pts-0.jishnu
groupdel, groupmems, groupmod, useradd , usermod , chgrp, chown, ls, head, tail, top, ps, find, crontab, ftp commands, tar, rpm, rkhunter, Rsync, grep, netstat command switches, netstat command’s practical usages, OpenVZ commands, lsof command