Screen utility

Screen is a simple utility that maintains a session on the server that you can reattach to, so you don’t need to maintain a connection, or, if you get disconnected, you can reattach to your running session.
To start, type
    screen
or, to name the session:

    screen -S my_session_name
To detach from a session.

Press Ctrl-a then d. This leaves the session running in the background.
To reattach to a session (if it’s the only screen session you have running)-

    screen -r
If you have multiple detached sessions, you’ll need to reattach by specifying the session ID or name:

    screen -r <session_id>    screen -r my_session_name
List active sessions
    screen -ls
Managing Windows within a Session:
All screen commands within a session are prefaced with Ctrl-a.

  • Create a new window: Ctrl-a then c
  • Switch to the next window: Ctrl-a then n
  • Switch to the previous window: Ctrl-a then p
  • Switch to a specific window by number: Ctrl-a then 0 (or the desired window number)
  • List all windows: Ctrl-a then " (double quote)
  • Rename the current window: Ctrl-a then A
  • Kill the current window: Ctrl-a then k
Some more advanced features:

  • Split screen horizontally: Ctrl-a then S
  • Split screen vertically: Ctrl-a then |
  • Navigate between split regions: Ctrl-a then Tab
  • Enter copy mode (for scrolling and selecting text): Ctrl-a then [
  • Paste copied text: Ctrl-a then ]