Skip to content

Instantly share code, notes, and snippets.

@shamayn
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shamayn/f5699a1c21dd0fd81eb6 to your computer and use it in GitHub Desktop.
Save shamayn/f5699a1c21dd0fd81eb6 to your computer and use it in GitHub Desktop.
Intro to Screen
# Using screen to maintain sessions on a remote machine. (This also just works locally).
# ssh into your remote host e.g. ssh user@host
# sets up a screen session called mysession
screen -S mysession
# Exiting the terminal (e.g. shutting your laptop) will "detach" the screen session (i.e. run it in the background).
# To see what screen sessions are running:
screen -ls
# To reconnect
screen -R mysession # resumes a detached session or creates one if it doesn't exist
# Shortcut from localhost for ssh-ing and starting up screen. Consider alias-ing if you use this a lot.
ssh user@host screen -R mysession
# To navigate within screen, the command character is Control-a by default, e.g.
Control-a ? # help page that shows you all available commands
Control-a c # creates a new window within the same session
Control-a a # switches between windows
Control-a d # detach this screen session
exit # exiting will close this screen window
# My ~/.screenrc
# Change the command character to Control-b so that Control-a still skips to the front of the line
# e.g. Control-b ? is help, Control-b b will switch between windows
escape ^Bb
startup_message off # Turn off the splash page
defscrollback 30000 # 30000-line scrollback buffer
# Pair programming: http://wiki.networksecuritytoolkit.org/nstwiki/index.php/HowTo_Share_A_Terminal_Session_Using_Screen#Sharing_A_Screen_Session_With_Another_User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment