Screen

GNU Screen is a program that enables the user to create sessions and have several virtual terminals within a single terminal.

Emerge
Install with the  command:

Configuration
The configuration files are located in and.

Usage
General usage of.

Start session
Screen can be started with the following command:

Once started is will create a socket for the session in where   is the current user running screen.

Any key combination can be used within the session with the exception of + which initiates 's Command-Mode.

Give the session a reasonable name on start up:

Start a command in a session without attaching to it (similar to a daemon):

Commands
In Command Mode (after pressing +) the following key combinations can be used:

General

 * - Show quick help information.
 * - Detach from the current session, all windows will continue to run in the background.

Creating and managing windows

 * - create another window
 * or - Switch to the next window.
 * or - Switch to the previous window.
 * - Switch to window 0 (similar for 1-9).
 * , then a number or title - switch to window with given number or title, used to reach windows numbered above 9.
 * + - Switch to last used window.
 * + - Set title for window.
 * - Display a list of windows, which can be navigated with arrow keys and selected with or
 * - Display a non-interactive list of windows at the bottom of screen (see Hardstatus Customization)

Copy, paste, and scroll operations

 * - Begin "copy mode", which allows scrolling and copying of window contents with following keys.
 * + - Scroll up in copy mode.
 * + - Scroll down in copy mode.
 * arrow keys - Move the cursor in copy mode.
 * or - Begin or end copying.
 * = Paste the text copied in copy mode.

Logging and monitoring

 * + = start/stop logging everything displayed on current window. log will be saved as a file "screenlog.X" under the directory in which screen was run
 * = (disabled in default configuration) dump the current contents of the current window to a file named "hardcopy.X" under the directory in which screen was run
 * + = start/stop monitoring current window for activity, any output produced by a program will cause an alert
 * = start/stop monitoring for inactivity (i.e. a long and output producing command finishes runnning)

Resume session
After the session is detached, all the active terminals remain active and so do commands that did not finish. To list existing sessions:

To resume the session displayed above:

Multiuser
Initiate screen with a human readable session name:

All other clients to view (and act on) the active live terminal can join by running:

Then its like conference call style terminal.

Session within session recursion
You can use a Screen within a Screen session. This occurs when you connect to a another host's Screen session from within your Screen session.

To signal the secondary (remote) Screen session with the Meta key, you issue the key twice to signal the second (remote) Session.

Some tend to remap the Meta key on the other terminals so they don't have to count. However, if you use the console/terminal often, there tends to be a shortage of keys on the keyboard.

Hardstatus customization
Customizing the status line, or hardstatus line in GNU Screen terminology is quite common. The following will get you started.

Screenshot of what my hardstatus line looks like using the above hardstatus incantation, along with nine additional terminal titles (ie. screen -t bash 7 bash --noprofile") defined within the .screenrc file. Each terminal gives me Calendar (calcurse), HTop (htop), startx (manual startx/DWM WM), Root (su), WWW (elinks), EMail (mutt) and a multitude of additional (bash) shells for working in. (This screenshot unfortunately omits color.)

After quitting a text editor the contents of the edited file remain in the screen window
Add the following line to screen preferences file:

Programs with too much output make older window contents scrolled away
You can increase the scrollback buffer size with following line in your preferences file:

TTY auto-login with a GNU screen session
The following will allow your system to auto-login as your user, and automatically initiate a GNU Screen session on tty2. A good scenario for this; You're off the network, secluded from society, and you find entering a password is a bit redundant. The following demonstrates using the BASH Shell.

MinGetty will give you autologin capability along without having to use a password:

Comment-out the second TTY (ie. c2, or terminal number of your choosing) and add mingetty with autologin capability.

Replace the above "USER_NAME" with your login name!

Add a line within your boot loader's configuration file to specify loading the init #4 level. (Referencing the "scr2:4" level specified within the above inittab file.) Also, utilize the "nox" option as well. (As I can recall, the line ending with "4" specifies runlevel four in correspondence to the above inittab entry. And the nox avoids XDM starting(?) If something needs further documenting here for clarification, please do so!)

The following configuration states, use framebuffer at the specified screen size using nox and start init level 4.

At this point, your system can now auto login on TTY2 with your default shell. Assuming you're using the BASH shell, you can start GNU Screen automatically by adding the "screen" command to your $HOME/.bash_profile file. This file is executed automatically when you first login. (Make sure you start any subsequent BASH shells using the "bash --no-profile" switch, including shells started within the $HOME/.screenrc files!)

With a little further scripting within $HOME/.bash_profile and a second entry within /etc/inittab, you could specify runlevel 5 for auto logging in and starting your favorite graphical desktop. (ie. XFCE4, GNOME, KDE, ...) And, while still spawning a GNU Screen session onto the desktop. But this is getting a little off topic of this GNU Screen Wiki.

Enable 256 colors
In order for GNU Screen to allow applications or the terminal to use 256 colors, two requisites must be met:

1) The "term screen-256color" line must be specified prior to any 'screen' definitions. (ie. "screen -t Mail") The resulting side effect of specifying after 'screen' definitions, the $TERM variable will be defined as 'screen' instead of the required 'screen-256color', and applications will not be able to see the terminal supports 256 colors. 2) Requires both the application and terminal to be compiled with 256 color support.