The following scenarios were tested both on Fedora and Ubuntu, but should work on any linux distro at least.
If you want to try these examples out locally, just replace references to "@host" with "@localhost".
You may also find my screen settings and screen keyboard shortcut reference useful.

Reattaching to a terminal

i.e. connecting again from another place or at another time.

This is very useful as the managed programs keep running after you detach, even if they produce output, or you logout, or your dial-up hangs for e.g. Note Linux does not native support for reattaching processes to terminals (like VMS), so this is a very useful function indeed, and is a much better/easier solution than using disown or nohup. Of course screen must already be running before any of the managed programs.

To detach: Ctrla d
To reattach: screen -r

screen reattach

Multiple views of a terminal

i.e. simultaneously connecting from another place.

To attach: screen -x

screen multi view

Multiple users of a terminal

For security reasons, screen by default is installed so that other users within the system can not attach to your screen sessions. To allow this to be changed one must set screen to run SUID root by doing the following (once):
sudo chmod +s /usr/bin/screen
sudo chmod 755 /var/run/screen
Then user1 can share their session on host as follows:
screen -S shared-session
Ctrla :multiuser on
Ctrla :acladd user2

user2 on host can then connect to the shared session like:
ssh user2@host
screen -x user1/shared-session
screen multiple users

Multiple read-only users of a terminal

For example one could give a group of users a demo by setting up read-only access to locked down account. This is an extension to just sharing a screen session, so again screen must run SUID root as described above. Then one could create a locked down "guest" account like:
sudo su -
ln -sf bash /bin/rbash
useradd -s /bin/rbash guest
passwd guest #enter password

echo '
trap "" 2 3 19 #try to stop user getting to shell
echo "Welcome to the demo"
echo "You can enter Ctrl-ad to detach at any time or just close your terminal"
echo "You can message all users by doing, Ctrl-a: wall \"your message\""
echo -n "Press Enter to continue..." && read
screen -x user1/shared-session
exit' > ~guest/.profile
echo '. .profile' >> ~guest/.bash_profile #for fedora
user1 then runs a shared session on host as above and in addition makes guest connections read-only by doing:
Ctrla :aclchg guest -wx "#,?"
Ctrla :aclchg guest +x "colon,wall,detach"

guests then can connect to the read-only demo by just doing:
ssh guest@host

Note user1 can see who has attached and the the size of their terminals with Ctrla : displays. This can be used to tell people to resize their terminals, or user1 can resize their own to the largest acceptable to everyone.

Note also that the settings above allow users to "wall" questions or comments to the group. If one wanted a richer interaction mechanism, then it would be advised that the group logs into a parallel realtime chat sytem, like IRC for example.
screen multiple demo users
© Apr 17 2007