To keep SSH sessions running even if you disconnect, use tmux to create a persistent terminal session that stays active on the server.
What is Tmux and Why Use It?
tmux is a terminal multiplexer that allows you to create multiple terminal sessions from a single SSH connection. It enables you to detach and reattach sessions, which is particularly useful for maintaining long-running processes on a remote server without interruption.
When you SSH into a server and start a process, the process is typically tied to your session. If your connection drops, so does your process. tmux solves this by running your processes inside a session that remains active even if your connection is lost.
With tmux, your remote tasks can continue running even when you're not connected.
For developers and sysadmins working remotely, especially from a mobile device, this feature is invaluable. You can start a process on your server, disconnect, and reconnect later to check its progress or results.
How to Install and Start Tmux
Installing tmux is straightforward. On most Linux distributions, you can install it via your package manager. For example, on Debian-based systems, use:
sudo apt-get install tmuxOn Red Hat-based systems, the command would be:
sudo yum install tmuxOnce installed, starting a new tmux session is as simple as typing:
tmuxThis command opens a new session. You can then run any command or start any process within this tmux session.
Once you're in a tmux session, your commands are safe from disconnection.
To detach from the session without killing your process, press Ctrl-b followed by d. This will leave the session running in the background.
How to Reattach to a Tmux Session
One of the best features of tmux is the ability to reattach to a session. If you've detached from a session or lost connection, you can reattach by listing existing sessions with:
tmux lsThis command displays a list of active sessions. To reattach to a specific session, use:
tmux attach-session -t [session-name]Replace [session-name] with the actual name or number of the session you want to attach to. This will bring you back to where you left off.
Managing Multiple Tmux Sessions
tmux allows you to manage multiple sessions, which can be useful if you have several tasks running on the same server. You can create a new session with:
tmux new-session -s [session-name]You can switch between sessions without closing them. Use tmux ls to list sessions and tmux switch -t [session-name] to switch.
Sessions can also be named for better organization, making it easier to manage multiple projects or processes simultaneously.
How Does ShellSage Enhance Tmux Usage on Mobile?
While most mobile SSH clients like Termius and JuiceSSH allow you to connect to your servers, they do not provide features like real-time AI assistance or blast-radius previews. ShellSage enhances your mobile experience by integrating an AI assistant, Sage, which can explain command outputs and suggest corrections, making it easier to manage your sessions on the go.
Moreover, ShellSage offers voice input, allowing you to control your SSH sessions with voice commands, and a blast-radius preview to safely execute potentially dangerous commands. These features are not commonly found in other mobile SSH clients.
With ShellSage, managing tmux sessions on a mobile device becomes more intuitive and error-free, thanks to its user-friendly interface and AI-driven assistance.
⚡ Key takeaways
- ›Tmux allows SSH sessions to persist beyond disconnections.
- ›You can detach and reattach to tmux sessions easily.
- ›ShellSage enhances mobile SSH management with AI features.

