Long-running commands stop if your SSH session closes unless they are managed by a service or terminal multiplexer. screen and tmux let you detach from a command and reconnect later.

This is useful for temporary tasks, test servers, console-only installers, and one-off maintenance. For production game servers, a proper systemd service is usually better.

 

Install screen or tmux

On Ubuntu or Debian:

sudo apt update
sudo apt install screen tmux

On AlmaLinux, Rocky Linux, Oracle Linux, or CentOS:

sudo dnf install screen tmux

If dnf is not available on an older image, use yum instead.

 

Using screen

  1. Create a named session:
screen -S gameserver
  1. Start your command inside the screen session.
  2. Detach with CTRL + A, then D.
  3. List sessions:
screen -ls
  1. Reconnect later:
screen -r gameserver

Linux VPS terminal showing a detached screen session and reconnect command

 

Using tmux

tmux new -s gameserver

Detach with CTRL + B, then D. Reconnect with:

tmux attach -t gameserver

 

Useful session commands

CommandUse
screen -lsList screen sessions.
screen -r nameReconnect to a screen session.
tmux lsList tmux sessions.
tmux attach -t nameReconnect to a tmux session.

 

When not to use screen or tmux

If the command needs to start automatically after a reboot, use a systemd service instead. For Minecraft, use How to run a Minecraft server as a systemd service on a Linux VPS.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to connect to a Linux VPS with SSH

SSH is the normal way to manage a Linux VPS. It gives you a terminal on the server so you can...

How to update packages on a Linux VPS

Keeping packages updated helps patch security issues and keeps server tools compatible. Run...

How to create a sudo user on a Linux VPS

A sudo user lets you manage a Linux VPS without logging in as root for every task. This is safer...

How to secure SSH on a Linux VPS

SSH is the main way to manage a Linux VPS, so it should be secured before the server is used for...

How to check disk usage on a Linux VPS

Disk usage issues can stop updates, backups, logs, databases, and game saves from writing...