Screen

Screen is a virtual terminal manager.

Screen Commands

Screen commands are entered at the colon prompt command line. Press Ctrl-A then ':' (colon) to bring up the colon prompt.

Collaborative Editing

Same User

This section describes how to share a screen session with two or more terminal windows with the same user.

  1. Start screen from one terminal

  2. Use the 'sessionname' command to display the session name:

    : sessionname
    
  3. or, from another terminal:

    $ screen -ls
    

    To list the available sessions

  4. From another terminal, connect using the -x option:

    $ screen -x tty.host
    

or

    $ screen -x user/

or

    $ screen -x user/PID

Multiple Users

This section describes how to share a screen session with different users.

To enable screen to operate with multiple users, the binary must be setuid. This has security implications and you should really understand the implications before doing this. However, this process will not work with multiple users without it.

  1. On a Debian 5.0 (Lenny) system the necessary commands are:

    $ sudo chmod 4755 /usr/bin/screen
    $ sudo chmod 0755 /var/run/screen
    
  2. On a Debian 6.0 (Squeeze) system:

    $ sudo chown root.utmp /var/run/screen /usr/bin/screen
    $ sudo chmod 4755 /usr/bin/screen
    $ sudo chmod 0755 /var/run/screen
    $ sudo dpkg-statoverride --update --add root utmp 4755 /usr/bin/screen
    
  3. Optionally, create a password using mkpasswd:

    $ mkpasswd secret
    GYTJ0dhZKdLp6
    
  4. Start screen from a terminal

  5. Enable multi-user mode

    : multiuser on
    
  6. Enable the other user (optionally with the password created with mkpasswd):

    : acladd ${other_user} GYTJ0dhZKdLp6
    
  7. From the other user's terminal:

    $ screen -x ${targer_user}
    

    Note: If the target user has more than one session, you'll need to qualify it with the session name in the following form:

    $ screen -rx ${target_user}/[pid.]tty.host
    
  8. If you wish to revert the setuid changes, on a Debian 5.0 (Lenny) system the necessary commands are:

    $ sudo chmod 2755 /usr/bin/screen
    $ sudo chmod 775 /var/run/screen
    

Trouble Shooting

Cannot open your terminal '/dev/pts/1' - please check.

This is probably caused by using su to become another user before running screen and therefore simply not having rights to /dev/pts/1

The neatest solution appears to be to use the script program to create another shell. E.g.

# su - new_user
$ script /dev/null
$ screen

See:

-- Frank Dean - 30 Nov 2013

References

Related Topics: LinuxHintsAndTips

-- Frank Dean - 13 Mar 2010