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-athenc - Switch to the next window:
Ctrl-athenn - Switch to the previous window:
Ctrl-athenp - Switch to a specific window by number:
Ctrl-athen0(or the desired window number) - List all windows:
Ctrl-athen"(double quote) - Rename the current window:
Ctrl-athenA - Kill the current window:
Ctrl-athenk
Some more advanced features:
- Split screen horizontally:
Ctrl-athenS - Split screen vertically:
Ctrl-athen| - Navigate between split regions:
Ctrl-athenTab - Enter copy mode (for scrolling and selecting text):
Ctrl-athen[ - Paste copied text:
Ctrl-athen]