ShellSage
ShellSage mobile terminal productivity workflow
SSH BASICS

Keep SSH Sessions Alive with Tmux

Learn how to use tmux to maintain persistent SSH sessions, ensuring your remote work continues uninterrupted.


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 tmux

On Red Hat-based systems, the command would be:

sudo yum install tmux

Once installed, starting a new tmux session is as simple as typing:

tmux

This 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 ls

This 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

Priya Nair
Your Questions, Answered

Frequently Asked Questions

Use tmux to create a persistent terminal session that stays active even if you disconnect. This way, your processes continue running on the server.
Yes, you can use tmux through SSH clients on your phone. ShellSage makes this easier with voice input and AI assistance to manage sessions effectively.
Basic tmux commands include starting a session with <code>tmux</code>, detaching with <code>Ctrl-b d</code>, and reattaching with <code>tmux attach-session -t [session-name]</code>.
ShellSage provides AI-driven assistance, voice input, and a blast-radius preview, making SSH management on mobile devices more intuitive and safer.
ShellSage offers a free version with essential features. Advanced features may require a subscription or usage of your own OpenAI or Claude key.
ShellSage requires an internet connection for SSH and SFTP operations, but some local features may be available offline.
Yes, ShellSage can manage tmux sessions effectively, offering AI help and voice commands to streamline your workflow on mobile.
Download ShellSage free
ShellSage is an AI-first SSH terminal with Sage built in: it explains output, fixes broken commands, and previews the blast radius before anything runs. Start on the free Hobby plan with no credit card, and get a 7-day full-Pro trial when you want everything.
← More tutorials