Skip to content

Instantly share code, notes, and snippets.

@emadehsan
Created April 18, 2018 11:52
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save emadehsan/ad6e81ca595e99045abb391844f45346 to your computer and use it in GitHub Desktop.
Save emadehsan/ad6e81ca595e99045abb391844f45346 to your computer and use it in GitHub Desktop.
Screen Linux/Unix command cheat sheet

Install Screen

$ sudo apt install screen

Enter a new Screen Session

$ screen

Detach from current screen session

Ctrl + a + d

List screen sessions

$ screen -ls

List the processes

$ ps -e | grep PID_OF_SCREEN_SESSION

Enter a new screen session & giving it the name newScreenSession

$ screen -S newScreenSession

Reattach to a screen session

$ screen -r PID_OF_SCREEN_SESSION

Execute a command in a screen session (quit command in this case)

$ screen -X -S PID_OF_SCREEN_SESSION quit

Kill a session from within it

Ctrl + a + k

It is actually for killing windows from within screen sessions.

New Windows Session from within screen

Ctrl + a + c

List all windows in a session

Ctrl + a + w

Ctrl a "

Ctrl a n: move to next window

Ctrl a p: move to previous window

Kill all windows & session

Ctrl a \

Divide in the panes

Ctrl a |

Move to sibling pane

Ctrl a tab

Divide in the panes Horisontal

Ctrl a S

Remove a pane

Ctrl a X

Lock a session with a password

Ctrl a x

Run a command in a screen

$ screen -d -m python script.py

Screen bindings / help

Ctrl a ?

Type a screen binding command

Ctrl a :

Reference: https://www.youtube.com/watch?v=I4xVn6Io5Nw

@lucamosca1
Copy link

I would add re-attach to a screen: screen -x newScreenSession

@kevin3
Copy link

kevin3 commented Nov 2, 2021

Ctrl a + shift H for logging screen output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment