When you close your SSH connection, or it drops, anything you were running in it normally stops. That's a problem for long jobs, such as installing cPanel, running big updates, copying large files or restoring backups.

screen and tmux solve this. They keep your session running on the server, so you can disconnect, reconnect later, and pick up exactly where you left off. Both do the same job, so use whichever you prefer. If you're not sure, screen is the simplest to start with.

Both work on every operating system we offer: Ubuntu 22.04, 24.04 and 26.04, Debian 12 and 13, AlmaLinux 8, 9 and 10, and Rocky Linux 9 and 10.

Before you start

  • SSH access as root or as a user with sudo rights. If you're logged in as root, you can leave sudo off the commands.

Using screen

Install screen

Ubuntu/Debian:

sudo apt install -y screen

AlmaLinux/Rocky (screen comes from the EPEL repository):

sudo dnf install -y epel-release
sudo dnf install -y screen

Start a session

Give the session a name you'll recognise, for example install:

screen -S install

You'll be back at a normal prompt, but now inside screen. Run your long job here as usual.

Detach and leave it running

Press Ctrl+A, let go, then press D. You'll see [detached], and the job keeps running. You can now safely close your SSH connection. If your connection drops by accident, screen detaches automatically.

Reconnect to your session

Log back in over SSH, then list your sessions:

screen -ls

Reattach by name:

screen -r install

If you only have one session, screen -r on its own is enough. If screen says the session is still Attached, for example after a dropped connection, use screen -dr install to take it over.

End the session

When your job has finished, type exit inside the session to close it.

Handy screen keys (press Ctrl+A first, then the key):

  • D: detach
  • C: open a new window inside the session
  • N or P: go to the next or previous window
  • [: scroll mode, to look back through the output with the arrow keys. Press Esc to leave it.

Using tmux

tmux does the same job as screen, with extra features such as splitting the screen into panes.

Install tmux

Ubuntu/Debian:

sudo apt install -y tmux

AlmaLinux/Rocky:

sudo dnf install -y tmux

Common tmux commands

  • Start a named session: tmux new -s install
  • Detach and leave it running: press Ctrl+B, let go, then press D
  • List sessions: tmux ls
  • Reattach: tmux attach -t install, or just tmux attach if you only have one
  • End the session: type exit inside it

Handy tmux keys (press Ctrl+B first, then the key):

  • D: detach
  • C: open a new window
  • N or P: go to the next or previous window
  • %: split the screen side by side
  • ": split the screen top and bottom
  • Arrow keys: move between split panes
  • [: scroll mode, to look back through the output. Press Q to leave it.

Tips

  • Start screen or tmux before you begin a long job. You can't move a job that's already running into a session.
  • Sessions survive a dropped SSH connection, but not a server reboot.
  • Sessions belong to the user who started them. If you started one as root, reconnect as root to see it.

Troubleshooting

  • "There is no screen to be resumed": the session has ended, or you're logged in as a different user from the one who started it. Check with screen -ls.
  • "No match for argument: screen" on AlmaLinux/Rocky: the EPEL repository isn't enabled. Run sudo dnf install -y epel-release first, or use tmux instead, which doesn't need EPEL.
  • Ctrl+A or Ctrl+B doesn't seem to do anything: press and release the Ctrl combination first, then press the next key on its own.

Related guides

Need help?

Our Cloud VPS plans are self-managed, so you're responsible for installing, securing and maintaining the software on your server. If something on our side isn't working, such as the network, or your VPS won't boot, open a support ticket. New to your VPS? Start with our Cloud VPS Getting Started Guide.

Was this answer helpful? 1 Users Found This Useful (8 Votes)