screen Tutorial: Keep Terminal Sessions Running

screen lets you keep terminal sessions running even after disconnecting from SSH. It is useful for long-running jobs, remote administration and working with multiple shell windows inside one connection.

Start a screen session

screen

You can also name the session so it is easier to find later.

screen -S maintenance

Detach and reattach

To detach from a running session, press Ctrl-a then d. The command inside screen keeps running.

screen -ls
screen -r maintenance

Common shortcuts

  • Ctrl-a d: detach from the session
  • Ctrl-a c: create a new window
  • Ctrl-a n: move to the next window
  • Ctrl-a p: move to the previous window

For new systems, tmux is also a popular alternative, but screen remains useful on many servers.

Leave a Comment