Skip to content

Instantly share code, notes, and snippets.

@rrshaban
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrshaban/83c125c32e96bcc33cc3 to your computer and use it in GitHub Desktop.
Save rrshaban/83c125c32e96bcc33cc3 to your computer and use it in GitHub Desktop.

Two minute introduction to screen

Screen is super-useful because it allows you to run terminal commands without needing to have your terminal window open.

Think of a screen as a session: you can open a screen, start a script, and then detach from it. The script will keep running in the background, but you can keep doing whatever you were doing without affecting the script. More significantly, if you want to be able to step away from your terminal, or close your laptop, or let a task run overnight without needing you to be connected, use a screen.

This quick tutorial will walk you through the basic commands necessary to get a screen working without worrying about what's going on behind the scenes.

Start a screen session

$ screen -S <NAME>

Run whatever code you want

$ ruby download_the_entire_internet.rb

This will run inside the screen, so you can freely switch out of the screen if you want.

Switch out of the screen

Ctrl-a d (hold Ctrl+a and click d)

This won't affect anything running in the screen.

See what screens you currently have open

$ screen -ls

Like ls in a directory, but for screens! Cool!

Switch into a screen

$ screen -Dr <NAME>

This will now bring your terminal window into a specific screen.

Close a screen

$ exit from within the screen, or if you want to do it from your regular interface, you can run

$ screen -X -S <NAME> quit

???

Profit!

If you're curious about what more you can do with screen, check out a helpful guide or (if you're brave) the documentation.

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