Find file
Fetching contributors…
Cannot retrieve contributors at this time
126 lines (94 sloc) 4.16 KB
screen: |-
$ screen
$ screen -ls: to list running sessions
To connect to an already open session running in background, use "screen" with following options:
* -D -R Attach here and now. In detail this means: If a session is running, then reattach. If necessary detach and logout remotely first. If it was not running create it and notify the user. This is the author's favorite.
* -r Reattach to existing
* -d -r Reattach a session and if necessary detach it first.
* -d -R Reattach a session and if necessary detach or even create it first.
* -d -RR Reattach a session and if necessary detach or create it. Use the first session if more than one session is available.
* -D -r Reattach a session. If necessary detach and logout remotely first.
* -D -RR Attach here and now. Whatever that means, just do it.
* -r <PID> Reattach to the session with process ID of <PID>
=SCREEN COMMANDS (run within screen):=
All commands called from the "meta key": C-a (ctrl+a). Note: Case-sensitive.
Note: For 'old' ctrl-a, use C-a-a
C-a ?: Help (shows a list of commands)
(On some systems C-a h reportedly also works.)
C-a c: Create new window/terminal
C-a k: Kill window session
C-a d: Detaches from the window
C-a DD: Detaches from the window AND the ssh shell if you are in one.
C-a x: Lock the current screen session with the current user's password.
To select a window:
C-a " (quote): List windows: (select one and press enter)
C-a <digit> (the number of the screen)
C-a n, C-a p: Next/Previous screen
Split screens:
C-a S: Split (then use C-tab, C-<num>)
C-a tab: Move between splits
C-a Q: Un-Split
C-a :resize +N : increase current region height by N
C-a :resize -N : decrease current region height by N
C-a :resize N : set current region height to N
C-a :resize = : make all windows equally high
C-a :resize max : maximize current region height
C-a :resize min : minimize current region height
After creating a new window it is useful to name it:
C-a A and enter a name.
To create a named window directly:
C-a :, and type screen <command>.
Copy mode so you can scroll up and down.:
Copy and Paste:
C-a [: Enables copy mode
C-a ]: Pastes buffer ('clipboard')
C-a <: Copy from a file
C-a >: Paste to a file
C-a M: Toggles alert on activity
C-a _ (underscore): Toggles monitor for silence
C-a " (quote): Jump to alerting window
==Sample ~/.screenrc==
hardstatus alwayslastline
##what is displayed
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}]'
## Default screens
## screen -t NameOfScreen ScreenNumber ShellCommand
#screen -t shell1 0
#screen -t shell2 1
#screen -t server 2 ssh me@myserver
## change meta-key (ctrl-a)
# escape ^gg
See also: kibitz (
Teacher: setuid root on /usr/bin/screen (NOTE! security risk, running as root?)
$ chmod u+s /usr/bin/screen
Teacher: To reset screen permissions after session: setuid owner
$ chmod u-s /usr/bin/screen
Teacher: $ screen -S SessionName.
Teacher: Ctrl-a :multiuser on
Teacher: Ctrl-a :acladd student_login_id
Student: $ ssh student@teacherComputer
Student: screen -x username/session.
=Serial Console Access:=
screen /dev/tty.usb* <connection speed>
screen /dev/ttyS[0-9] <connection speed>
Typical values for connection speed are 9600 or 115200
=Helpful sites:=