Linux and Unix screen command
Quick links
About screen
Syntax
Examples
Linux and Unix main page
Screen manager with VT100/ANSI terminal emulation.
Command-line Options
Default key bindings
screen [-opts] [cmd [args]]
or: screen -r [host.tty]
| -a | Force all capabilities into each window's termcap. |
| -A -[r|R] | Adapt all windows to the new display
width & height. |
| -c file | Read configuration file instead of '.screenrc'. |
| -d (-r) | Detach the elsewhere running screen (and reattach here). |
| -dmS name | Start as daemon: Screen session in detached mode. |
| -D (-r) | Detach and logout remote (and reattach here). |
| -D -RR | Do whatever is needed to get a screen session. |
| -e xy | Change command characters. |
| -f | Flow control on, -fn = off, -fa = auto. |
| -h lines | Set the size of the scrollback history buffer. |
| -i | Interrupt output sooner when flow control is on. |
| -l | Login mode on (update /var/run/utmp), -ln = off. |
| -list or -ls | Do nothing, just list our SockDir. |
| -L | Turn on output logging. |
| -m | ignore $STY variable, do create a new screen session. |
| -O | Choose optimal output rather than exact vt100 emulation. |
| -p window | Preselect the named window if it exists. |
| -q | Quiet startup. Exits with non-zero return code if unsuccessful. |
| -r | Reattach to a detached screen process. |
| -R | Reattach if possible, otherwise start a new session. |
| -s shell | Shell to execute rather than $SHELL. |
| -S sockname | Name this session <pid>.sockname instead of <pid>.<tty>.<host>. |
| -t title | Set title. (window's name). |
| -T term | Use term as $TERM for windows, rather than "screen". |
| -U | Tell screen to use UTF-8 encoding. |
| -v | Print "Screen version 4.00.03 (FAU) 23-Oct-06". |
| -wipe | Do nothing, just clean up SockDir. |
| -x | Attach to a not detached screen. (Multi display mode). |
| -X | Execute <cmd> as a screen command in the specified session. |
As mentioned, each screen command consists of a "C-a" followed by one other character. For your convenience, all commands that are bound to lower-case letters are also bound to their control character counterparts (with the exception of "C-a a"; see below), thus, "C-a c" as well as "C-a C-c" can be used to create a window. See section "CUSTOMIZATION" for a description of the command.
The following table shows the default key bindings:
| C-a ' | (select) | Prompt for a window name or number to switch to. |
| C-a " | (windowlist -b) | Present a list of all windows for selection. |
| C-a 0-9 | (select 0-9) | Switch to window number 0 - 9, or to the blank window. |
| C-a tab | (focus) | Switch the input focus to the next region. |
| C-a C-a | (other) | Toggle to the window displayed previously. Note that this binding defaults to the command character typed twice, unless overridden. For instance, if you use the option "-e]x", this command becomes "]]". |
| C-a a | (meta) | Send the command character (C-a) to window. See escape command. |
| C-a A | (title) | Allow the user to enter a name for the current window. |
|
C-a b C-a C-b | (break) | Send a break to window. |
| C-a B | (pow_break) | Reopen the terminal line and send a break. |
|
C-a c C-a C-c | (screen) | Create
a new window with a shell and switch to that window. |
| C-a C | (clear) | Clear the screen. |
|
C-a d C-a C-d | (detach) | Detach screen from this terminal. |
| C-a D D | (pow_detach) | Detach and logout. |
|
C-a f C-a C-f | (flow) | Toggle flow on, off or auto. |
| C-a F | (fit) | Resize the window to the current region size. |
| C-a C-g | (vbell) | Toggles screen's visual bell mode. |
| C-a h | (hardcopy) | Write a hardcopy of the current window to the file "hardcopy.n". |
| C-a H | (log) | Begins/ends logging of the current window to the file "screenlog.n". |
|
C-a i C-a C-i | (info) | Show info about this window. |
|
C-a k C-a C-k | (kill) | Destroy current window. |
|
C-a l C-a C-l | (redisplay) | Fully refresh current window. |
| C-a L | (login) | Toggle this windows login slot. Available only if screen is configured to update the utmp database. |
|
C-a m C-a C-m | (lastmsg) | Repeat the last message displayed in the message line. |
| C-a M | (monitor) | Toggles monitoring of the current window. |
|
C-a space C-a n C-a C-n | (next) | Switch to the next window. |
| C-a N | (number) | Show the number (and title) of the current window. |
|
C-a backspace C-a h C-a p C-a C-p | (prev) | Switch
to the previous window (opposite of C-a n). |
|
C-a q C-a C-q | (xon) | Send a control-q to the current window. |
| C-a Q | (only) | Delete all regions but the current one. |
|
C-a r C-a C-r | (wrap) | Toggle the current window's line-wrap setting (turn the current window's automatic margins on and off). |
|
C-a s C-a C-s | (xoff) | Send a control-s to the current window. |
| C-a S | (split) | Split the current region into two new ones. |
|
C-a t C-a C-t | (time) | Show system information. |
| C-a v | (version) | Display the version and compilation date. |
| C-a C-v | (digraph) | Enter digraph. |
|
C-a w C-a C-w | (windows) | Show a list of window. |
| C-a W | (width) | Toggle 80/132 columns. |
|
C-a x C-a C-x | (lockscreen) | Lock this terminal. |
| C-a X | (remove) | Kill the current region. |
|
C-a z C-a C-z | (suspend) | Suspend screen. Your system must support BSD-style job-control. |
| C-a Z | (reset) | Reset the virtual terminal to its "power-on" values. |
| C-a . | (dumptermcap) | Write out a ".termcap" file. |
| C-a ? | (help) | Show key bindings. |
| C-a C-\ | (quit) | Kill all windows and terminate screen. |
| C-a : | (colon) | Enter command line mode. |
|
C-a [ C-a C-[ C-a esc | (copy) | Enter copy/scrollback mode. |
| C-a ] | (paste .) | Write the contents of the paste buffer to the stdin queue of the current window. |
|
C-a { C-a } | (history) | Copy and paste a previous (command) line. |
| C-a > | (writebuf) | Write paste buffer to a file. |
| C-a < | (readbuf) | Reads the screen-exchange file into the paste buffer. |
| C-a = | (removebuf) | Removes the file used by C-a < and C-a >. |
| C-a , | (license) | Shows where screen comes from, where it went to and why you can use it. |
| C-a _ | (silence) | Start/stop monitoring the current window for inactivity. |
| C-a * | (displays) | Show a listing of all currently attached displays. |
Screen will allow you to have multiple screens doing different tasks without having to connect (SSH) multiple times into the same computer. Below is a quick overview on how to navigate and use screen.
screen
Typing screen without any options will start a new screen, often with no messages or notice indicating that a new screen has started. To view the available commands press C-a (Ctrl + a) and then let go and press a ? to see available options. To switch between active screens press C-a multiple times.
If you want to start another screen press C-a and then C to start a new window.
If you want to close a screen window press C-a and then K. When entered correctly you'll be prompted if you really want to quit the window.
To detach from a screen press C-a and then d. This will keep the screen active, even when logging off and can be reattached the next time you connect.
screen -ls
To view attached and detached screens type the above command. This will give you output similar to the below example.
There is a screen on:
8254.pts-0.host (Detached)
1
Socket in /var/run/screen/S-hope.
This is useful for when you loose your session or logout while waiting on a process to complete. To re-attach to a detached screen type screen -r <screen name>. Using the above example we'd type screen -r 8254.pts-0.host.
