For remote sessions, tmux is the better choice over screen in most cases: it reattaches or creates a session in one command (tmux new -A -s main), offers consistent scripting through subcommands and targets, and is developed in a public repository. screen remains a sound option on older servers where it is already installed and you cannot add packages.

screen and tmux reattach commands side by side

tmux new -A -s main attaches to the session named “main” if it exists and creates it if it does not; in screen, screen -d -R main does something similar. These are the everyday equivalents:

# screen
screen -S main          # create a named session
screen -ls              # list sessions
screen -r main          # reattach
screen -d -r main       # detach it elsewhere and reattach
screen -x main          # share it with another attached terminal
# detach: Ctrl-a d

# tmux
tmux new -s main        # create a named session
tmux ls                 # list sessions
tmux attach -t main     # reattach
tmux attach -d -t main  # detach other clients and reattach
tmux new -A -s main     # reattach, or create if missing
# detach: Ctrl-b d

The flag you will reach for most from a phone is -d. If you left the session attached on your laptop and connect from your phone, tmux attach -d detaches the other client so the session is yours alone. Without -d, both clients share the session and window size follows tmux's window-size option.

Sharing is sometimes the point: screen -x and tmux attach without -d let two people watch and type in the same terminal while debugging an incident.

screen vs tmux comparison table for remote sessions

screen and tmux solve the same problem, keeping processes alive on the server after you disconnect, but they differ in prefix key, scripting model and configuration:

What is comparedscreentmux
Reattach or create in one stepscreen -d -R nametmux new -A -s name
Default prefixCtrl-a, clashes with the shell's beginning-of-lineCtrl-b, fewer clashes in the shell
Sending commands from a script-X with internal commands such as stuffSubcommands targeting -t session:window.pane
Reading a window's outputhardcopy to a filecapture-pane -p to standard output
Configuration file~/.screenrc~/.tmux.conf
Check installed versionscreen -vtmux -V

Scripting tmux vs screen: send-keys, capture-pane and stuff

tmux send-keys types into a specific pane and tmux capture-pane -p prints that pane's contents to standard output, so a script can start a job and check its progress without ever attaching to the session.

# tmux: start a background copy and check its output
tmux has-session -t backup 2>/dev/null || tmux new-session -d -s backup
tmux send-keys -t backup 'rsync -a /srv/data/ /mnt/backup/' Enter
tmux capture-pane -p -t backup | tail -n 5

# screen: rough equivalent
screen -dmS backup
screen -S backup -X stuff $'rsync -a /srv/data/ /mnt/backup/\n'
screen -S backup -X hardcopy /tmp/backup.txt
tail -n 5 /tmp/backup.txt

In screen, -X sends an internal command to the session: stuff types text and hardcopy dumps the screen to a file you then have to read. It works, but every check goes through an intermediate file.

tmux also exposes formats for querying state: tmux list-sessions -F '#{session_name} #{session_attached}' prints each session name and how many clients are attached, which suits a login script that decides whether to reuse or create. If you forget the syntax, termi1's AI types the command at the prompt without pressing Enter, so you review it before running it.

screen and tmux shortcuts on a mobile keyboard

screen's prefix is Ctrl-a, the same keystroke that moves the cursor to the start of the line in bash and zsh with emacs-style bindings; inside screen you press Ctrl-a then a to pass it to the shell. tmux uses Ctrl-b, and the prefix is changed in ~/.tmux.conf:

# ~/.tmux.conf: use Ctrl-a like screen
set -g prefix C-a
unbind C-b
bind C-a send-prefix

Keeping Ctrl-b avoids the shell clash; switching to Ctrl-a only pays off if you have years of screen muscle memory. On a phone the real obstacle is different: the system keyboard hides Ctrl, Esc and Tab. The keyboard in termi1, a mobile SSH terminal adds Esc, Ctrl, Tab, arrow keys and an fn layer with F1–F12, PgUp/PgDn, Home and End. That covers Ctrl-b [ for tmux copy mode, Ctrl-a [ in screen and prefix plus PgUp to scroll back through history. An optional account syncs connections and shortcuts across devices.

screen and tmux maintenance status: how to check it

tmux -V and screen -v print the installed version, the first thing to check before copying a configuration from another machine: options from a recent ~/.tmux.conf can fail on an older release.

tmux is developed in the open, with issues, change notes and a wiki in the official tmux GitHub repository. screen is part of the GNU project and ships in many distributions; check its release history through your system's package manager rather than relying on hearsay.

The practical rule: if the server already has tmux, use it; if only screen is available and you do not control packages, screen is perfectly adequate for keeping a long job alive. For new deployments and scripts meant to last, pick tmux.

tmux with Mosh to keep sessions alive from a phone

Mosh uses UDP, by default on ports 60000-61000, and starts mosh-server over an initial SSH connection, so your firewall must allow that range as well as OpenSSH's TCP port 22.

mosh admin@server -- tmux new -A -s main

The two layers complement each other. Mosh keeps the connection up when your phone switches from Wi-Fi to mobile data; tmux keeps your processes running if you close the client or come back from another machine. Mosh does no port forwarding or X11 forwarding, so tunnels still need plain SSH; details are in the official Mosh documentation. termi1 follows the same pattern: Mosh to survive network changes, tmux so whatever you left running is still there, and built-in SFTP to move files without leaving the session. For servers without a public IP, a private mesh network without ports such as Prialo, or Tailscale, avoids opening anything to the internet.

Frequently asked questions

Can a screen session be converted into a tmux session?

A screen session cannot be converted into a tmux session: its processes stay tied to screen until they exit. The usual approach is to let them finish inside screen, reattach with screen -r to check on them, and start any new work in tmux.

How do I reattach to tmux when the session shows as attached?

A tmux session marked as attached is still open in another client. tmux attach -d -t name detaches that client and attaches you; without -d you will share the session. tmux ls lists existing sessions and shows which ones are attached.

What happens to tmux if the SSH connection drops?

tmux keeps running on the server when the SSH connection drops, because the session does not depend on the client. Your processes continue, and after reconnecting, tmux attach or tmux new -A -s main returns you to the same window with its scrollback.

Do I need tmux if I already use Mosh?

tmux is still useful alongside Mosh, because Mosh keeps the connection alive through network changes but cannot reattach from another client or device. tmux holds your processes on the server; combined as mosh server -- tmux new -A -s main, both failure cases are covered.