Screen terminal multiplexer

From Alpine Linux
Revision as of 13:00, 4 November 2008 by Mhavela (talk | contribs) (Use 'screen' on Alpine)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This document is a short note on how to monitor what's happening on the console.


Install programs

 apk_add screen


Make it autostart

Lets edit /etc/profile and add the following code to it:

 if [ -n "$PS1" ] && [ -z "$STARTED_SCREEN" ] && [ -z "$SSH_TTY" ]; then
   STARTED_SCREEN=1 ; export STARTED_SCREEN
   screen -RR && exit 0
   echo "Screen failed! continuing with normal bash startup"
 fi


Not only the console...

The above example holds the if-statement:

 && [ -z "$SSH_TTY" ]

This statement sees to that no ssh-sessions is forced into a screen.
In case you want ssh-sessions to be forced into a screen, this option can be omitted.


Check for available sessions

To check what available screen-sessions are available:

 screen -list

You might get a list that looks like this:

 There are screens on:
         11151.pts-1.mhlab01     (Attached)
         11131.pts-3.mhlab01     (Attached)
 2 Sockets in /var/run/screen/S-root.


Attach to a session

Lets say you want to attach to a existing session (e.g. the above "11131.pts-3.mhlab01" session).

 screen -x pts-3


Help

'screen' has various options/commands.
When your inside a 'screen'-session you can:

 CTRL+a ?

(Don't hold CTRL when entering '?')