You are here
Using screen for support and/or surveillance
See also Byobu.
Often support customers want to see what you do on their databases. For this screen
is the ideal tool.
Screen
commands typically look like this:
screen> Ctrl+a ?
This means press Ctrl+a
, release Ctrl+a
, press ?
and NOT press Ctrl+a+?
together. Often you can find Ctrl+A
which is wrong. It is a lower case a!
Start first screen
Start and leave a screen:
shell> screen screen> exit
or k
for kill
screen> Ctrl+a k
Comment: Does not work if done with sudo
, typically used with ssh
.
A screen can be named as follows:
shell> screen -S support
List available screens
You can find your available screens like this:
user1_shell> screen -ls There are screens on: 11212.support (05/21/2012 03:10:23 PM) (Attached) 5358.pts-4.master (05/21/2012 03:08:08 PM) (Attached) 2 Sockets in /var/run/screen/S-user1.
User2
cannot see those:
user2_shell> screen -ls No Sockets found in /var/run/screen/S-user2.
but user2
can see all screens like this:
user2_shell> ps -ef | grep screen | grep -v grep user1 5357 24626 0 15:08 pts/4 00:00:00 screen user1 11211 11105 0 15:10 pts/7 00:00:00 screen -S support
Screen help
You get help about screen:
shell> screen --help shell> man screen screen> Ctrl+a ?
Create a new window in screen
To create several windows in screen use c for create:
screen> Ctrl+a c
List all available windows:
screen> Ctrl+a "
Scroll to previous/next or nth window:
screen> Ctrl+a n screen> Ctrl+a p screen> Ctrl+a 0 screen> Ctrl+a 1
Detach and re-attach to a screen
Detach from screen:
screen> Ctrl+a d
List available screens and attach to a screen:
shell> screen -ls shell> screen -r 4670.pts-4.master
Logging screen sessions
Ctrl+a h
Configure screen
# # ~/.screenrc # # Don't show the slash screen startup_message off # Use visual bell vbell on # Set a big scrolling buffer defscrollback 5000 # Support UTF-8 defutf8 on
Assign meaningful names to a screen window
screen> Ctrl+a A Server1
Scroll in screen
Start scroll mode:
screen> Ctrl+a ESC
Then scroll up and down. To get back in normal screen mode press ESC
.
Lock/unlock screen
screen> Ctrl+a s screen> Ctrl+a q
Sharing screen with same shell user
user1_shell> screen -S support user1_shell> screen -r support There is a screen on: 17831.support (05/21/2012 03:36:29 PM) (Attached) There is no screen to be resumed matching support. user1_shell> screen -r support -x
Caution: If one of both windows does an exit, both windows will close!
If you get the following error message: Cannot open your terminal '/dev/pts/2' - please check.
the following can help (as the owner of the device):
chmod 666 /dev/pts/2
Sharing screen with other shell user
You have to prepare as user root
:
chmod u+s /usr/bin/screen chmod 755 /var/run/screen
Then as user1
:
user1_shell> screen -S support user1_screen> Ctrl+a :multiuser on user1_screen> Ctrl+a :acladd user2
and as user2
:
shell_user2> screen -x user1/support