Tmux in Termux – Terminal Multiplexer and Session Manager

Tmux is a terminal multiplexer that lets you run multiple terminal sessions inside a single window. It allows you to split the terminal into different panes, create multiple windows, and switch between sessions. You can also keep your terminal sessions running in the background and reconnect to them later.

Here’s what you can do with Tmux in Termux:

  • Create multiple terminal sessions.
  • Split the terminal into horizontal and vertical panes.
  • Open multiple terminal windows.
  • Switch between different sessions.
  • Run commands in the background.
  • Detach and reattach terminal sessions.
  • Manage multiple tasks in one terminal.
  • Keep running processes active after closing the terminal session.

Install Tmux in Termux

Below is the command to install Tmux in Termux, just copy and run the command in your Termux.

Update and upgrade the packages:

pkg update && pkg upgrade -y

Install Tmux:

pkg install tmux -y

Once the installation is complete, Tmux is ready to use in your Termux terminal.

Use Tmux in Termux

Here are some basic Tmux commands to create and manage sessions, switch between windows, and control terminal panes. You can also use keyboard shortcuts to perform common tasks quickly.

Start a new Tmux session:

tmux

Create a named session:

tmux new -s mysession

List all active sessions:

tmux ls

Detach from the current session:

Press:

Ctrl + B, then D

Reattach to a session:

tmux attach -t mysession

Kill a session:

tmux kill-session -t mysession

Kill all Tmux sessions:

tmux kill-server

Tmux Keyboard Shortcuts

Tmux uses Ctrl + B as its default prefix key. Press the prefix key first, then press the shortcut key.

Session and Window Commands:

  • Ctrl + B, then D – Detach from the current session.
  • Ctrl + B, then C – Create a new window.
  • Ctrl + B, then N – Move to the next window.
  • Ctrl + B, then P – Move to the previous window.
  • Ctrl + B, then W – List available windows.
  • Ctrl + B, then , – Rename the current window.
  • Ctrl + B, then $ – Rename the current session.

Pane Management Commands:

  • Ctrl + B, then % – Split the terminal vertically.
  • Ctrl + B, then " – Split the terminal horizontally.
  • Ctrl + B, then an arrow key – Move between panes.
  • Ctrl + B, then X – Close the current pane.
  • Ctrl + B, then Z – Zoom in or out of the current pane.
  • Ctrl + B, then O – Switch to the next pane.
  • Ctrl + B, then Q – Show pane numbers.

Other Useful Shortcuts:

  • Ctrl + B, then [ – Enter copy mode to scroll through terminal output.
  • Ctrl + B, then ] – Paste copied text.
  • Ctrl + B, then ? – Show all keyboard shortcuts.

These commands and shortcuts help you manage multiple terminal sessions in Tmux. You can switch between windows, split panes, and control your sessions without opening multiple terminal windows.

End Note

Tmux is a useful tool for managing multiple terminal sessions in Termux. It allows you to split your screen, switch between windows, run multiple commands, and keep processes running in the background. It is especially useful when working with multiple terminal tasks at the same time.

SHARE THIS POST: