139 lines
4.4 KiB
Text
139 lines
4.4 KiB
Text
= GNU screen terminal commands cheat sheet
|
|
:author: Yuri Slobodyanyuk
|
|
|
|
Author: Yuri Slobodyanyuk, https://www.linkedin.com/in/yurislobodyanyuk/
|
|
|
|
NOTE: `C-a` below stands for `Ctrl + a` keyboard sequence.
|
|
|
|
[cols=2,options="header"]
|
|
|===
|
|
|
|
|Command
|
|
|Description
|
|
|
|
|*~/.screenrc* & */etc/screenrc*
|
|
| Commands that the `screen` runs on start up.
|
|
|
|
|*screen -ls*
|
|
|List active screen sessions
|
|
|
|
|*screen -Q windows*
|
|
|List windows' names inside screen session
|
|
|
|
|*screen -S <session name>*
|
|
|Create a new screen session with the name <session name>
|
|
|
|
|*screen -x*
|
|
|
|
*screen -r <session name>*
|
|
|
|
|Attach to the running session, also by its name
|
|
|
|
|*screen -dRR*
|
|
|Attach to the screen session, detach on other display if attached. If no session exists, will create a new one.
|
|
|
|
|*C-a d*
|
|
| Detach from the session, session keeps running. Here, and further *C* means Ctrl.
|
|
|
|
|*C-a c*
|
|
|Create new window in the session.
|
|
|
|
|*C-a C-a*
|
|
|Switch to the previous window.
|
|
|
|
|*C-a "*
|
|
|List all windows with option to navigate and enter any of them.
|
|
|
|
|*C-w*
|
|
|Show a list of active windows with their numbers.
|
|
|
|
|*C-a <number>*
|
|
|Switch to the window number _number_.
|
|
|
|
|*C-a '*
|
|
|Switch to the window by its name.
|
|
|
|
|*C-a n*
|
|
|Switch to the next window.
|
|
|
|
|*C-a p*
|
|
|Switch to the previous window.
|
|
|
|
|
|
|*exit*
|
|
|Exit and close current window. If it was the last window in a session, exits `screen` terminating the session.
|
|
|
|
|*C-a k*
|
|
|Kill the current window forcefully (not recommended).
|
|
|
|
|*C-a : quit*
|
|
| Quit screen session completely terminating it. Alternatively - exit all screen windows.
|
|
|
|
|*C-a A*
|
|
|Rename current window.
|
|
|
|
|*C-a S*
|
|
|Split windows display horizontally. Use *C-a c* to create a new window inside the new split or *C-X* to close this part of split.
|
|
|
|
|*C-a \|*
|
|
|Split windows display vertically. Available starting screen 4.01, i.e. not available on Mac 2020 which still uses screen 4.00.
|
|
|
|
|*C-a tab*
|
|
|Jump to the next region in a split window display.
|
|
|
|
|*C-a Q*
|
|
| Unsplit the window, leaving the current window active.
|
|
|
|
|*C-a [* or *C-a <esc>*
|
|
|Enter buffer navigation mode to scroll output buffer, copy, edit and paste later. Navigation commands as per `vim` if Vim is set as editor.*<esc>* to leave the buffer mode.
|
|
|
|
|*<space>*
|
|
|Start/stop selection while in the buffer mode to select the text. Press `<space>` or `<Enter>` to copy the selected text. E.g. to select/copy the whole buffer: `C-a [ gg <space> G <space> <esc>`
|
|
|
|
|*C-a ]*
|
|
|Paste the selected text at the cursor of the terminal, or create a new window and say start Vim there and paste into it while in Insert mode.
|
|
|
|
|*C-a h*
|
|
|Dump the contents of the currently visible terminal to `hardcopy.<n>` file, where _n_ is auto-incrementing number of your window.
|
|
|
|
|*C-a H*
|
|
|Start/end logging all output of the curent window into a file `screenlog.N` where `N` is the window number. The data is appended, not overwritten if the file exists. Output printed before that is not logged.
|
|
|
|
|*C-a a*
|
|
| Send `Ctrl-a` sequence to the shell in the window, useful to jump to the beginning of the line.
|
|
|
|
|*C-a M*
|
|
|Monitor window for activity. When enabled, will notify you of any acitvity while you work in other window.
|
|
|
|
|*C-a _*
|
|
| Monitor window for 30 seconds of silence, will notify you in any other window as `Window 0: silence for 30 seconds`
|
|
|
|
|*C-a ?*
|
|
|Show all key bindings help.
|
|
|
|
|
|
|*Save session state*
|
|
|This is not possible. If you use the same layout each session, you can put start up commands to re-create it in `.screenrc` file in your home directory, but still - you cannot save the current session state, i.e. contents of the windows and their layout.
|
|
|
|
2+|*Sharing session (e.g. for pair programming/tutoring)*
|
|
|
|
|
|
a|Original session (say _user1_):
|
|
|
|
. Set suid root bit on `screen` binary: `sudo chmod +s /usr/bin/screen`
|
|
. Inside session you want to share: `C-a :` then `multiuser on` to enable sharing session.
|
|
. Add usernames to share the session with: `C-a :` `acladd <username>`
|
|
|
|
Connecting user (say _user2_):
|
|
|
|
. Run in shell: `screen -x <sharing username>/`, in our example `screen -x user1/`
|
|
|
|
|Sets up sharing the session. Another user connecting to the session views real-time its output, can enter and run commands himself. Also see *aclchg*, *acldel*, *aclgrp* for controlling what the connecting user can and cannot do. E.g. to remove _write_ permissions from all users on all windows: `:aclchg * -w #`
|
|
|
|
|*C-a **
|
|
| See who is connected to your shared screen session.
|
|
|
|
|
|
|===
|
|
|
|
Follow me on https://linkedin.com/in/yurislobodyanyuk/ for updates.
|