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.
Start screen from one terminal
Use the 'sessionname' command to display the session name:
: sessionnameor, from another terminal:
$ screen -lsTo list the available sessions
From another terminal, connect using the -x option:
$ screen -x tty.hostwhere
tty.hostis the session name from above.or
$ screen -x user/or
$ screen -x user/PIDwhere user is the username of the user running screen and 'PID' is the process ID shown in the session name from above.
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.
On a Debian 5.0 (Lenny) system the necessary commands are:
$ sudo chmod 4755 /usr/bin/screen $ sudo chmod 0755 /var/run/screenOn 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/screenOptionally, create a password using mkpasswd:
$ mkpasswd secret GYTJ0dhZKdLp6Start screen from a terminal
Enable multi-user mode
: multiuser onEnable the other user (optionally with the password created with mkpasswd):
: acladd ${other_user} GYTJ0dhZKdLp6From 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.hostIf 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:
- http://centosforge.com/node/how-solve-cannot-open-your-terminal-devpts1-please-check
- http://pc-freak.net/blog/how-to-work-around-screen-cannot-open-your-terminal-devpts1-please-check/
- http://serverfault.com/questions/116775/sudo-as-different-user-and-running-screen/116830#116830
-- Frank Dean - 30 Nov 2013
References
- http://en.wikipedia.org/wiki/Setuid
- http://aperiodic.net/screen/multiuser
- http://www.debian-administration.org/article/Using_GNU_screen%27s_multiuser_feature_for_remote_support
Related Topics: LinuxHintsAndTips
-- Frank Dean - 13 Mar 2010