Skip to content

Instantly share code, notes, and snippets.

@shivai
Last active June 27, 2021 13:55
Show Gist options
  • Save shivai/0d262d27db8e0297933437f161703b4a to your computer and use it in GitHub Desktop.
Save shivai/0d262d27db8e0297933437f161703b4a to your computer and use it in GitHub Desktop.
Screen- Linux commands

Screen Commands:

Exit the detached screen:

screen -X -S [session # you want to kill] quit

How to go to a screen:

screen -r [session]

How to detach:

ctrl+a d

Create a new screen into another screen:

ctrl+a c

Move between screens:

ctrl+a n/p

Kill detached:

screen -X -S SCREENID kill

Send command to the running previus screen

screen -S yoursession-name -p 0 -X stuff "ls^M"    --> put your command in "" and put ^M

If you omit ^M, screen will just type ls onto your terminal but not send the ENTER key afterwards.

Run a command in screen without attaching

screen -S something -d -m ping 8.8.8.8

Copy mode

ctrl-a escape

with -h you can specifie the number of lines that you want to keep, if the output is huge set it to high number

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