GNU Screen

This page was last modified on 7 November 2011, at 00:18. This page has been accessed 1,561 times.

From RBOSE

Jump to: navigation, search

Contents

GNU Screen

Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. Each virtual terminal provides the functions of the DEC VT100 terminal and, in addition, several control functions from the ANSI X3.64 (ISO 6429) and ISO 2022 standards (e.g., insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal.


How to

How to open a screen

Starting a new session

To start a new session on your side one has to type:

screen -S <session_name>

example: screen -S test


Joining existing session

screen -x <user/session_name>

example: screen -x user1/test , or for you user just: screen -x test


How to allow other users to join sessions you create

To let other users join you session you must make it a multiuser session, and add users to the its access list:

  1. Activate the screen's command line: press CTRL+a , then press : and enter first command:
    multiuser on
  2. open command line again and enter:
    addacl user1,user2,user3,... 
    this will add the users to access list of current screen session


Listing existing sessions

screen -ls


How to add a new window to session

To open a new window in existing session:

press CTRL+a, then press c


How to switch between several windows

To switch between windows we have several options

  1. CTRL+a, then press one of the numbers 0,1,2,3,4, ...
  2. CTRL+a, then again CTRL+a -- this will switch in cycle between the last 2 windows you've been active in
  3. CTRL+a , then " (double quote) -- open list of windows and navigate with cursor keys, select by pressing ENTER
  4. CTRL+a, then n -- go to next window


How add colors, server name, time, window title and date

Settings of your screen are storred in ~/.screenrc

Activate the screen's command line: press CTRL+a , then press : and enter first command:

title DevBox
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w %{.rW}%n %t%{-}%+w %=%{..w}%u %{..G} %H %{..Y} %Y-%m-%d %c:%s "

Example of configuration:

# An alternative hardstatus to display a bar at the bottom listing the
# windownames and highlighting the current windowname in blue. (This is only
# enabled if there is no hardstatus setting for your terminal)
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w %{.rW}%n %t%{-}%+w %=%{..w}%u %{..G} %H %{..Y} %Y-%m-%d %c:%s "

How to exit screen

  • If you want to close the screen, then type CTRL+d -- it will kill active window, and if only one window is running you will kill the screen session.
  • To detach yourself from screen session, so you can leave it running and join later press CTRL+a and then press d


How to move around in screen

  • Sometimes, scroll comes fast and you want to look back up. It is possible:
    • press Ctrl+A, then the [ key.
    • with keys h, j, k and L you can now move around
  • Find more info and other commands in the screen manual


Documentation