How to Use tmux in Termux — Run Multiple Sessions on Android (2026 Guide)
- Introduction — Why tmux Changes Everything in Termux
- What Is tmux and How Does It Work?
- How to Install tmux in Termux
- Core tmux Commands — Sessions, Windows, and Panes
- Advanced tmux Usage — Scripting and Config
- Real-World Use Cases for tmux in Termux
- Common Errors and Fixes
- Pro Tips for Power Users
- tmux vs Screen — Full Comparison
- Frequently Asked Questions
- Conclusion
// 01 — Introduction — Why tmux Changes Everything in Termux
If you have been using tmux in Termux for a while, you already know how limiting a single terminal window can feel. You start a long download, and suddenly you cannot run anything else. You switch between tasks and lose track of what was running where. You close Termux for a second and your entire session is gone. Sound familiar? That frustration ends today.
tmux — short for Terminal Multiplexer — is one of the most powerful tools you can install on your Android device through Termux. It lets you split your screen into multiple panes, run several terminal sessions at the same time, switch between running tasks instantly, and — most importantly — keep your sessions alive even when you close the Termux app or your screen turns off. Think of it as a superpower for your phone's terminal.
Whether you are a cybersecurity student learning ethical hacking, a developer running background scripts, or just someone who loves Linux on Android, tmux is a tool you will use every single day once you learn it. It is completely free, requires no root, and works flawlessly in Termux on any modern Android device.
In this guide, written by Rixon Xavier for HYDRA TERMUX, you are going to learn everything from scratch. We start with what tmux actually is and how it works under the hood. Then we walk through installation step by step. After that, we cover every core command you need — sessions, windows, panes, detaching, reattaching — all explained clearly so even a complete beginner can follow along. By the end, you will know how to configure tmux, write basic automation scripts with it, and use it for real cybersecurity and development workflows on your Android phone.
No root is required. No previous Linux experience is needed. Just an Android phone with Termux installed and the willingness to learn. Let's get into it.
// 02 — What Is tmux and How Does It Work?
Before you type a single command, it helps to understand what you are actually installing. tmux in Termux is not just another terminal app — it is a layer that sits on top of your terminal and gives it powers that a normal shell simply does not have.
The Core Concept — Server and Client
tmux works using a server-client model. When you launch tmux for the first time, it quietly starts a background server process. That server is what actually holds all your sessions, windows, and panes. Your visible terminal is just a client that connects to that server. This is the key reason why tmux sessions survive even after you close your Termux window — the server keeps running in the background, holding everything exactly as you left it.
This architecture is genius for mobile use. On Android, apps get paused or killed when you switch away. But because the tmux server runs as a separate process tied to Termux's environment rather than its window, your long-running commands — port scans, file downloads, compilation jobs — keep going even when your screen is off.
Sessions, Windows, and Panes — The Three Layers
tmux organises your work into three layers, and understanding these layers is the foundation of using tmux effectively:
Sessions are the top-level containers. Each session is a completely independent workspace. You might have one session called "hacking" for your cybersecurity tools and another called "dev" for your coding projects. Sessions are what you detach from and reattach to.
Windows live inside sessions. Think of them like browser tabs. Inside your "hacking" session you might have one window for Nmap and another window for a Python script. You switch between them with a keyboard shortcut. Each window takes up your full screen.
Panes live inside windows. This is where things get visually interesting. You can split a single window into multiple panes — side by side or top and bottom — so you can see two or more terminals at once. Run a scan in the left pane and watch the output in the right pane. It is incredibly useful.
The Prefix Key — How tmux Listens to You
Everything in tmux is controlled through a special key combination called the prefix key. By default this is Ctrl + B. You press the prefix, release it, then press another key to give tmux a command. For example, pressing Ctrl+B then D detaches from your session. This takes about five minutes to get used to and then becomes second nature.
On Android with a software keyboard, Ctrl+B can be tricky to press. We will cover how to remap this to something more thumb-friendly in the configuration section later in this guide.
// 03 — How to Install tmux in Termux (Step by Step)
Installing tmux in Termux is one of the easiest things you will ever do. The Termux package manager handles everything for you. Before installing, make sure your Termux packages are up to date — this avoids dependency conflicts and ensures you get the latest stable version of tmux.
Open Termux and Update Packages
First thing first — always update before installing anything. This refreshes your package lists and upgrades outdated packages.
pkg update && pkg upgrade -y
This command does two things. pkg update refreshes the package index from Termux's repositories. pkg upgrade -y upgrades all currently installed packages to their latest versions. The -y flag automatically answers "yes" to all prompts so you do not have to keep pressing Enter. Depending on how many packages need upgrading, this might take a minute or two. Let it finish completely before moving on.
Install tmux
Now install tmux with a single command.
pkg install tmux -y
Termux will download and install tmux along with any required dependencies. The package is small — typically under 1 MB — so this completes in seconds even on a slow connection.
Verify the Installation
Check that tmux installed correctly and see which version you have.
tmux -V
You should see output like:
tmux 3.4
If you see a version number, tmux is installed and ready to use. If you get a "command not found" error, run the update and install commands again and make sure your internet connection was active during installation.
Launch tmux for the First Time
Start your first tmux session.
tmux
Your terminal will clear and you will notice a green status bar at the bottom of the screen. That bar shows your session name, window number, window name, and the current time. That green bar is your confirmation that you are now inside a tmux session. Welcome to a whole new way of using Termux.
// 04 — Core tmux Commands — Sessions, Windows, and Panes
This is the section you will refer back to most often. Learning these tmux commands in Termux is what makes the tool actually useful. We will cover them in a logical order — sessions first, then windows, then panes — with clear explanations for every single one.
Session Commands
Sessions are the foundation of your tmux workflow. Here is how to work with them:
Create a new named session:
tmux new-session -s mysession
The -s flag sets a name for your session. Naming sessions is optional but highly recommended. When you have multiple sessions running, names make it easy to know which one to reattach to. Replace mysession with anything meaningful — like hacking, dev, or downloads.
Detach from the current session (keep it running in background):
Ctrl+B then D
This is the magic command. Pressing the prefix (Ctrl+B), releasing it, then pressing D detaches you from the session. The session does not stop — it keeps running in the background. You can close Termux entirely and come back later and everything is still there.
List all running sessions:
tmux ls
Output will look something like this:
hacking: 2 windows (created Mon Mar 2 10:14:33 2026)
dev: 1 window (created Mon Mar 2 09:55:01 2026)
This tells you each session name, how many windows it has, and when it was created. Very handy when you come back after a break and forget what you left running.
Reattach to a named session:
tmux attach-session -t mysession
Replace mysession with your session name. If you only have one session running, you can just type tmux attach as a shortcut.
Kill a specific session:
tmux kill-session -t mysession
Window Commands
Windows are like tabs inside your session. All window commands use the prefix key:
Ctrl+B C — Create a new window
Ctrl+B N — Move to the next window
Ctrl+B P — Move to the previous window
Ctrl+B 0-9 — Jump directly to window number 0 through 9
Ctrl+B , — Rename the current window
Ctrl+B W — Show a list of all windows to select from
Ctrl+B & — Close the current window (confirms before closing)
Pane Commands
Panes let you see multiple terminals on screen at the same time. This is one of the best features of tmux for learning and working:
Ctrl+B % — Split the current pane vertically (side by side)
Ctrl+B " — Split the current pane horizontally (top and bottom)
Ctrl+B Arrow Key — Move focus to the pane in that direction
Ctrl+B Z — Zoom the current pane to full screen (press again to unzoom)
Ctrl+B X — Close the current pane
Ctrl+B Q — Show pane numbers briefly for quick navigation
Ctrl+B Z to zoom into one pane when you need to read output carefully, then zoom back out to see all panes again.// 05 — Advanced tmux Usage — Config Files and Scripting
Once you have the basics down, the real power of tmux in Termux comes from customisation. The tmux configuration file lets you remap keys, change colours, enable mouse support, and set your preferences so every new session starts exactly the way you want. For Android users especially, a good config file makes tmux dramatically more comfortable to use.
Creating Your tmux Configuration File
The tmux config file lives at ~/.tmux.conf. It does not exist by default — you create it yourself. Let's build one that makes tmux much more usable on Android.
nano ~/.tmux.conf
Now paste or type the following configuration:
# Change the prefix key from Ctrl+B to Ctrl+A (easier on mobile)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support (tap to select panes on touchscreen)
set -g mouse on
# Start windows and panes at index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer to 10000 lines
set -g history-limit 10000
# Enable vi-style copy mode
setw -g mode-keys vi
# Split panes using easier keys
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Reload config with Prefix + R
bind r source-file ~/.tmux.conf \; display "Config Reloaded!"
# Set status bar style
set -g status-style bg=black,fg=green
set -g status-left "#[fg=cyan][#S] "
set -g status-right "#[fg=yellow]%H:%M %d-%b-%Y"
Save the file with Ctrl+X, then Y, then Enter. Now reload the config inside a running tmux session:
tmux source-file ~/.tmux.conf
Let's break down the most important settings. Changing the prefix to Ctrl+A is a game changer on mobile — it is much easier to reach than Ctrl+B. Enabling mouse support means you can tap a pane to select it instead of using arrow keys. The history limit increase means you can scroll back through thousands of lines of output, which is essential when reviewing long scan results or log files. Binding | and - for splits is far more intuitive than the defaults — vertical split on | and horizontal on - visually match how the split will actually look.
Scripting tmux — Launch a Full Workspace Automatically
Here is where tmux gets really powerful. You can write a shell script that automatically creates a session, opens multiple windows, runs commands in each one, and leaves everything ready for you. This means instead of setting up your workspace every time, you run one script and you are immediately productive.
Here is an example script that creates a cybersecurity learning workspace:
#!/bin/bash
# hydra-workspace.sh — Auto-launch tmux cybersecurity workspace
SESSION="hydra"
# Kill existing session if it exists
tmux kill-session -t $SESSION 2>/dev/null
# Create new session with first window named "main"
tmux new-session -d -s $SESSION -n "main"
# Create second window named "tools"
tmux new-window -t $SESSION:2 -n "tools"
# Create third window named "notes"
tmux new-window -t $SESSION:3 -n "notes"
# In window 1: show system info
tmux send-keys -t $SESSION:1 "uname -a && echo 'Workspace ready!'" Enter
# In window 2: split into two panes
tmux split-window -h -t $SESSION:2
# Start at window 1
tmux select-window -t $SESSION:1
# Attach to the session
tmux attach-session -t $SESSION
Save this as workspace.sh, make it executable with chmod +x workspace.sh, and run it with ./workspace.sh. Every time you open Termux you can run this one script and your entire working environment is ready in seconds.
// 06 — Real-World Use Cases for tmux in Termux
Theory is great, but let's talk about how actual users use tmux in Termux every day. These real-world workflows show why tmux is not just a cool tool — it is an essential one for anyone serious about using Termux productively on Android.
Use Case 1 — Running Long Scans Without Interruption
One of the most common frustrations in Termux is running a long Nmap scan or a directory bruteforce and having it killed when your phone screen turns off or you switch apps. With tmux, this is completely solved. Start your scan inside a tmux session, detach from it, and go do something else. The scan keeps running. When you come back an hour later, reattach and check the results.
# Start a tmux session named "scan"
tmux new-session -s scan
# Run your nmap scan inside tmux
nmap -sV -p 1-65535 192.168.1.1 -oN scan_results.txt
# Press Ctrl+A then D to detach (session keeps running)
# Later, reattach to check results:
tmux attach-session -t scan
Use Case 2 — Multi-Pane Monitoring Dashboard
Split your tmux window into four panes and run different monitoring tools in each one simultaneously. Watch system resources in one pane, monitor network traffic in another, tail a log file in a third, and keep your main shell ready in the fourth. This kind of setup turns your Android phone into a surprisingly capable monitoring station.
# After opening tmux, split into four panes:
# Split vertically to get left and right
Ctrl+A |
# Focus left pane, split horizontally for top-left and bottom-left
Ctrl+A -
# Focus right pane, split horizontally for top-right and bottom-right
Ctrl+A Arrow-Right
Ctrl+A -
# Now run commands in each pane:
# top-left pane: top
top
# bottom-left pane: ping
ping google.com
# top-right pane: tail a log
tail -f /var/log/syslog
# bottom-right pane: interactive shell ready
Use Case 3 — Running Multiple Tools Simultaneously
In cybersecurity practice and CTF challenges, you often need several tools running at the same time. Maybe you have a web server running in one window, a Python exploit script in another, and netcat listening for a connection in a third. Without tmux this is nearly impossible on a phone. With tmux it is completely manageable.
# Window 1: Simple HTTP server
python3 -m http.server 8080
# Create window 2 (Ctrl+A C), run netcat listener
nc -lvp 4444
# Create window 3 (Ctrl+A C), run your script
python3 exploit.py
Use Case 4 — SSH into Remote Servers
If you manage remote servers or VPS instances, tmux becomes even more valuable. SSH into your server from Termux inside a tmux session, and even if your mobile connection drops briefly, the tmux session on the remote server keeps running. When you reconnect and re-SSH, everything is exactly where you left it. No lost work, no interrupted processes.
# SSH to your server
ssh user@yourserver.com
# On the server, start tmux
tmux new-session -s server-work
# Do your work, then detach
# If connection drops, reconnect with SSH and then:
tmux attach-session -t server-work
Use Case 5 — Learning and Practice Environment
For cybersecurity students and beginners, tmux creates the ideal learning environment. Open a tutorial or documentation in one pane using a text-based browser like w3m, and practice the commands in the adjacent pane. No more switching between apps to read and type — everything is on one screen. This alone makes learning in Termux dramatically more efficient.
// 07 — Common Errors and Fixes
Error: "no server running on /data/data/com.termux/files/usr/tmp/tmux-*"
This error appears when you try to attach to a session but no tmux server is running. It means all previous sessions have ended. Simply start a fresh one with tmux or tmux new-session -s name.
Error: "sessions should be nested with care" Warning
You see this warning when you try to launch tmux while already inside a tmux session. This is not a fatal error — it is just tmux warning you that you are nesting sessions. To start an inner tmux session intentionally, use tmux new-session -s inner. To avoid confusion, just be aware of whether you are already in tmux before launching it again. Check by looking for the status bar at the bottom of your screen.
Error: Config Changes Not Taking Effect
If you edited ~/.tmux.conf but nothing changed, you need to reload the config. Inside a tmux session run:
tmux source-file ~/.tmux.conf
Alternatively, kill your current session and start a new one — tmux always reads the config fresh when starting a new session.
Error: Mouse Mode Not Working
If you enabled set -g mouse on in your config but tapping does not select panes, make sure you reloaded the config. Also, some Android keyboards intercept touch events. Try long-pressing the screen instead of a quick tap when selecting panes.
Error: Scrolling Does Not Work in tmux
Normal finger swiping does not scroll tmux output by default. You need to enter scroll mode first:
# Enter scroll mode
Ctrl+A [
# Use arrow keys or Page Up/Down to scroll
# Press Q to exit scroll mode
If you enabled mouse support in your config, you can also use two-finger scroll on some Android setups, but this depends on your keyboard app and device.
// 08 — Pro Tips for Power Users
tmux new-session -s projectname and Ctrl+A , to rename windows. Future you will be very grateful.tmux to the end of your ~/.bashrc file so tmux starts automatically every time you open Termux. Or better, use a script that attaches to an existing session if one exists, or creates a new one if none does.# Add to ~/.bashrc for auto-attach behavior
if command -v tmux &>/dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t main || tmux new-session -s main
fi
Ctrl+A [, navigate to text with arrow keys, press Space to start selecting, move to end of selection, press Enter to copy. Paste with Ctrl+A ].Ctrl+A : then type capture-pane -p > output.txt and press Enter.tmuxinator — a Ruby-based tool that reads YAML config files to build elaborate tmux setups. It is not in the Termux default repo but can be set up with gem if you have Ruby installed.// 09 — tmux vs Screen — Full Comparison
tmux is not the only terminal multiplexer available in Termux. screen is an older tool that does similar things. Here is how they compare so you can make an informed choice — though for most users, tmux is the clear winner in 2026.
| Feature | tmux | screen |
|---|---|---|
| Pane splitting | ✅ Yes (vertical and horizontal) | ⚠️ Limited (vertical only in newer versions) |
| Session persistence | ✅ Yes | ✅ Yes |
| Mouse support | ✅ Full mouse support | ❌ No mouse support |
| Config file | ✅ ~/.tmux.conf (powerful) | ⚠️ ~/.screenrc (limited options) |
| Status bar | ✅ Highly customisable | ⚠️ Basic |
| Scripting / automation | ✅ Excellent | ⚠️ Limited |
| Active development | ✅ Actively maintained | ⚠️ Slower updates |
| Learning curve | ⚠️ Slightly steeper | ✅ Slightly easier initially |
| Community and docs | ✅ Excellent | ⚠️ Smaller community |
| Available in Termux | ✅ Yes | ✅ Yes |
The verdict is clear. tmux wins on almost every front. The only scenario where screen might make sense is if you are already deeply familiar with it from previous experience. For anyone starting fresh, invest your time learning tmux — it is the standard tool used by professionals worldwide and the skills transfer directly to any Linux environment.
// 10 — Frequently Asked Questions
tmux kill-session -t sessionname. To kill all sessions and the tmux server entirely: tmux kill-server. After killing the server, no tmux sessions will remain and the next time you run tmux it will start completely fresh.termux-clipboard-set command.// 11 — Conclusion — Start Using tmux in Termux Today
You have just learned everything you need to make tmux in Termux a central part of how you work on Android. From the basic concepts of sessions, windows, and panes, to installation, core commands, configuration, automation scripting, and real-world use cases — this guide has covered the full picture.
The single biggest takeaway is this: once you start using tmux, you will not understand how you ever managed without it. The ability to detach from a running session, go do something else, and come back to find everything exactly as you left it is transformative for mobile Linux use. It removes the fragility that makes long-running tasks in Termux frustrating, and it opens up workflows that simply are not possible in a standard single-window terminal.
Start small. Install tmux today, create a named session, split it into two panes, and just use it for a week. By the end of that week, the prefix key shortcuts will feel natural, you will have a basic ~/.tmux.conf configured to your taste, and you will be thinking about all the other ways tmux can make your Termux setup more powerful.
For more Termux guides like this one — covering tools, workflows, and cybersecurity education — bookmark hydratermux.blogspot.com and check back regularly. New tutorials are published regularly, all free, all tested, and all written for real Android users who take their terminal seriously.

Comments
Post a Comment