tmux is a terminal multiplexer: one terminal window that holds many shells, split into panes, grouped into windows, and kept alive on the server when your SSH connection drops. It is the simplest way to run a long job on a remote server without losing it. This guide covers the commands you use every day, a clean config file, and a few server workflows.
Start or rejoin a session with tmux new -As main. Press Ctrl+b (the prefix), then % or " to split, an arrow key to move between panes, c for a new window and d to detach. Reattach later with tmux a. tmux runs on your own VPS or computer; it is not installed on Domain India shared hosting.
1. Sessions, windows and panes
main or deploy. It keeps running on the server after you disconnect.Almost every shortcut starts with the prefix, Ctrl+b by default: press and release it, then press the key.
2. Install and start
sudo apt install tmux # Debian, Ubuntu
sudo dnf install tmux # AlmaLinux, Rocky Linux, Fedora
brew install tmux # macOS with Homebrew
tmux -V # check the versionOn Windows, use tmux inside WSL. Then start a named session:
tmux new -s work # new session called "work"
tmux ls # list sessions
tmux a -t work # attach to "work"
tmux new -As main # attach to "main", or create it if it doesn't exist3. Everyday keys
| Action | Keys (after Ctrl+b) |
|---|---|
| Detach and leave everything running | d |
| New window | c |
| Next or previous window | n or p |
| Pick a window or session from a tree | w |
| Rename the window | , |
| Split side by side | % |
| Split top and bottom | " |
| Move between panes | Arrow keys |
| Resize the pane | Ctrl + arrow keys (hold Ctrl) |
| Zoom a pane to full size and back | z |
| Close the pane | x (or type exit) |
| Move the pane to its own window | ! |
| Scroll and search (copy mode) | [ then q to leave |
| List all key bindings | ? |
In copy mode, use the arrow keys or Page Up and Page Down to scroll, and / to search (with vi keys enabled as below). Paste the last copied text with Ctrl+b ].
4. A clean ~/.tmux.conf
This config works on tmux 3.x on Linux, macOS and WSL. Save it as ~/.tmux.conf, then reload it from inside tmux with Ctrl+b : followed by source-file ~/.tmux.conf.
# Behaviour
set -g mouse on # click panes, drag borders, scroll with the wheel
set -g history-limit 50000 # longer scrollback
set -sg escape-time 10 # no lag after Esc in vim
set -g focus-events on
set -g base-index 1 # windows start at 1
setw -g pane-base-index 1
set -g renumber-windows on
# Easier splits that open in the current folder
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Copy mode with vi keys; copy to the system clipboard where the terminal allows it
setw -g mode-keys vi
set -g set-clipboard on
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Status line
set -g status-left "#[bold]#S "
set -g status-right "%d %b %H:%M | #H"set-clipboard on copies through your terminal (OSC 52), which works in most modern terminals, including over SSH. If yours doesn't support it, replace the y binding with copy-pipe-and-cancel and the right command for your system: pbcopy on macOS, wl-copy on Wayland, xclip -selection clipboard -i on X11, or clip.exe in WSL.
Prefer Ctrl+a, like GNU Screen? Add these three lines:
unbind C-b
set -g prefix C-a
bind C-a send-prefix5. Server workflows
- Survive a dropped connection.Before a long upgrade, import or build, run
tmux new -As main, start the job, and detach withCtrl+b d. If Wi-Fi drops, SSH in again and runtmux a: the job is still running. - Watch while you work.Split once for a shell and once for
journalctl -fu nginxortail -fon your app log, so you see errors the moment they happen. - Deploy and verify.One pane runs the deploy, one follows the logs, and one repeats a health check with
curl -I https://example.com/health. - Save the output.
tmux capture-pane -S -5000 -p > deploy.logwrites the pane's scrollback to a file for your notes.
It is easy to type into the wrong pane. Run destructive commands, such as database drops or rm -r, in a separate window with a clear name, and check the prompt's hostname first. Never use synchronize-panes (typing into every pane at once) on production servers unless you mean it.
6. Sharing a session safely
Two people logged in as the same user can simply attach to the same session: tmux a -t pair. Add -r for a read-only viewer, which is safer for demos. Sharing between different users means opening up tmux's socket with custom permissions, which gives the other user control of your shell; on a server, avoid it and never share a root session.
7. Plugins and saved layouts
The tmux plugin manager, TPM, installs plugins from ~/.tmux.conf:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpmset -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # save and restore sessions
run '~/.tmux/plugins/tpm/tpm'Reload the config, then press Ctrl+b I (capital i) to install. tmux-resurrect saves your windows and panes with Ctrl+b Ctrl+s and restores them after a reboot with Ctrl+b Ctrl+r. To start the same layout for a project every time, tools such as tmuxp or tmuxinator describe it in a YAML file.
8. Troubleshooting
- Mouse scroll doesn't work: check
set -g mouse onand reload. Some terminals need Shift held to select text with the mouse. - Delay after pressing Esc in vim: lower
escape-time, as in the config above. - Broken lines or odd characters: set a UTF-8 locale on the server, such as
export LANG=C.UTF-8, and use a font with box-drawing characters. - Colours look wrong: add
set -g default-terminal "tmux-256color", and make sure your terminal advertises 256 colours or true colour.
9. Using tmux with Domain India
tmux and GNU Screen are not installed on Domain India cPanel or DirectAdmin shared hosting, including inside the jailed SSH shell (checked on our servers in September 2026), and Windows (Plesk) hosting has no SSH. On shared hosting, keep long jobs off the command line: use cron jobs in the control panel, or split large imports into smaller pieces. SSH on shared hosting is jailed and off by default; see enabling and accessing jailed SSH.
On a Domain India VPS you have full root access, so install tmux with your distribution's package manager as shown above. The VPS is self-managed, and tmux is exactly the tool for running updates and deploys over SSH safely. New to your server? See how to access your VPS after purchase.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
Prices on the cards exclude 18% GST.
How do I keep a command running after my SSH connection drops?
Start it inside tmux, for example after running tmux new -As main, then detach with Ctrl+b d. The session keeps running on the server. Reconnect with SSH and run tmux a to return to it.
How do I split the screen in tmux?
Press Ctrl+b then % to split side by side, or Ctrl+b then " to split top and bottom. Move between panes with Ctrl+b and an arrow key.
How do I scroll up in tmux?
Press Ctrl+b then [ to enter copy mode, scroll with the arrow keys or Page Up, and press q to leave. With set -g mouse on in your config, the mouse wheel scrolls too.
How do I change the tmux prefix to Ctrl+a?
Add unbind C-b, set -g prefix C-a and bind C-a send-prefix to ~/.tmux.conf, then reload the file with source-file or start a new tmux server.
Can I use tmux on Domain India shared hosting?
No. tmux and GNU Screen are not installed on Domain India cPanel or DirectAdmin shared hosting, including inside the jailed SSH shell. Install tmux on a Domain India VPS, where you have full root access.
What is the difference between tmux and GNU Screen?
Both keep sessions alive after you disconnect. tmux has easier pane splitting, a more flexible status line, better scripting and an active plugin ecosystem, so most new setups choose tmux.
Ready to work on a server where long jobs survive a dropped connection? Look at VPS plans with full root access, or open a support ticket to ask which plan suits your workload.
Full root access on KVM with NVMe storage, so you can install tmux and the rest of your toolkit.
See VPS plans