Back to course

Using Tmux/Screen for Persistent Sessions

Termux Masterclass: From Zero to Linux Power User on Android

38. Using Tmux/Screen for Persistent Sessions

One major limitation of mobile terminals is that closing the app or switching away might cause background processes to pause or die. Session multiplexers like tmux and screen solve this by allowing sessions to persist even if the app closes.

What is a Session Multiplexer?

It runs a persistent shell session on the server (your Android device). You can detach from it and reattach later, even after closing Termux entirely.

Option 1: Termux Session Management (Built-in)

Termux supports multiple sessions. Swipe right from the left edge (or use volume down + K) to open the session panel.

  • New Session: Start a new Termux instance.
  • Naming sessions is done via a long-press on the session title.

Option 2: Using tmux (Recommended)

tmux (Terminal Multiplexer) is modern and highly feature-rich. It allows splitting the terminal screen into multiple panes and windows within one session.

  1. Installation: bash $ pkg install tmux

  2. Start a new session: bash $ tmux new -s mysession

  3. Detach: Press Ctrl + B, then press D. (You will be returned to the main shell.)

  4. Close Termux and Reopen.

  5. Reattach: bash $ tmux attach -t mysession

Your session and any running background processes within tmux will be exactly as you left them.