Linux screen Command
The Linux screen command is used for multi-window management.
Screen is a multi-window manager that runs in a full-screen text mode. It is typically used when logging into a host via telnet or using an older terminal.
Syntax
screen [-AmRvx -ls -wipe][-d <job_name>][-h <lines>][-r <job_name>][-s <shell>][-S <job_name>]
Parameter Description:
-A: Adjust all windows to the current terminal size.
-d<job_name>: Detach the specified screen job.
-h<lines>: Specify the number of lines in the window buffer.
-m: Force the creation of a new screen job even if one is already active.
-r<job_name>: Resume a detached screen job.
-R: Attempt to resume a detached job. If none are found, create a new screen job.
-s<shell>: Specify the shell to execute when creating a new window.
-S<job_name>: Specify the name of the screen job.
-v: Display version information.
-x: Resume a previously detached screen job.
-ls or --list: Display all current screen jobs.
-wipe: Check all screen jobs and remove those that are no longer usable.
Examples
Create a screen terminal
# screen // Create a screen terminal
Create a screen terminal and execute a task
# screen vi ~/main.c // Create a screen terminal and run the vi command
Detach from a screen terminal
# screen vi ~/main.c // Create a screen terminal and run the vi command
#include
main ()
{
}
"~/mail.c" 0,0-1
Press Ctrl+a d in the screen terminal
Reconnect to a detached screen terminal
# screen -ls // Display created screen terminals
There are screens on:
2433.pts-3.linux (October 20, 2013 16:48:59) (Detached)
2428.pts-3.linux (October 20, 2013 16:48:05) (Detached)
2284.pts-3.linux (October 20, 2013 16:14:55) (Detached)
2276.pts-3.linux (October 20, 2013 16:13:18) (Detached)
4 Sockets in /var/run/screen/S-root.
# screen -r 2276 // Connect to the screen terminal with ID 2276