From IT Mission Linux Tips, Hacks, Tutorials, Howtos -

Main: GNU-Screen

GNU Screen terminal emulation


Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).


       screen [ -options ] [ cmd [ args ] ]
       screen -r [[pid.]tty[.host]]
       screen -r sessionowner/[[pid.]tty[.host]]

Getting Started with screen for the first time.

Step 1 create fresh screen session:

screen -S <Yourname>

-S sessionname

When creating a new session, this option can be used to specify a meaningful name for the session.

This name identifies the session for "screen -list" and "screen -r" actions. It substitutes the default [] suffix.

The first window (the one you're actually using) is numbered as 0, while future windows will be labeled as 1, 2, 3 etc.

Step 2 create a new window.

Ctrl+a and then press c (create).

List the window created.

Step 3 To detach from this session, press

Ctrl+a d.

Step 4 To kill not responding programs, use

Ctrl+a K.

Step 5 To see the screen sessions created.

screen -list

Step 6 To re-attach to a detached session, open a terminal and type.

screen -r <session>

Step 7 Sharing a screen session

chmod +s /usr/bin/screen

screen -S sessionName

Ctrl+a: acladd username, where username is the Unix user for the second user.

screen -x sessionName

Step 8 To scroll back through screen's history.

Step 9 To split the screen in two

Step 10 Help within Screen.

Screen key bindings, page 1 of 2.

                       Command key:  ^A   Literal ^A:  a

   break      ^B b          lockscreen ^X x          reset      Z
   clear      C             log        H             screen     ^C c
   colon      :             login      L             select     '
   copy       ^[ [          meta       a             silence    _
   detach     ^D d          monitor    M             split      S
   digraph    ^V            next       ^@ ^N sp n    suspend    ^Z z
   displays   *             number     N             time       ^T t
   fit        F             only       Q             title      A
   flow       ^F f          other      ^A            vbell      ^G
   focus      ^I            pow_break  B             version    v
   help       ?             pow_detach D             width      W
   history    { }           prev       ^P p ^?       windows    ^W w
   info       i             readbuf    <             wrap       ^R r
   kill       K             redisplay  ^L l          writebuf   >
   lastmsg    ^M m          remove     X             xoff       ^S s
   license    ,             removebuf  =             xon        ^Q q

^]  paste [.]
"   windowlist -b
-   select -
0   select 0
1   select 1
2   select 2
3   select 3
4   select 4
5   select 5
6   select 6
7   select 7
8   select 8
9   select 9
I   login on
O   login off
]   paste .

Step 11 Help from command help.

Use: 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.02 (FAU) 5-Dec-03".
-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.

How to split the terminal into more than one “view”?


Ctrl+A then c creates a new window.
Ctrl+A then A sets the name of the current window.
Ctrl+A then a digit from 0 to 9 switches to that window.
Ctrl+A then " displays a list of all windows.
Ctrl+A then S splits the current window in two.
Ctrl+A then Ctrl+I changes the focus to the next window.
Ctrl+A then x locks Screen (much like a screensaver).
Ctrl+A then d detaches from the current Screen session.

.screenrc file in our home directory:

cd;vi .screenrc

Add the following two lines, keeping in mind that everything after the first line (bind X remove) is one single line:

bind X remove
hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]'

Save and exit.

Retrieved from
Page last modified on August 16, 2014, at 02:39 AM