Tmux

How to use tmux

  1. Start tmux by typing tmux in your terminal. This creates a new session and attaches to it.

  2. Run any commands or programs as you normally would. For example, to simulate a long-running process: sleep 10m (This command will pause for 10 minutes).

  3. Detach from your tmux session by pressing Ctrl+B then D.

  4. List active tmux sessions with tmux ls.

  5. Reattach to the existing tmux session to resume where you left off: tmux attach -t <session_number> (Replace <session_number> with the desired session number from the tmux ls command).

Switching between tmux windows and creating new ones

  1. To create a new tmux window, press Ctrl-B then c.

  2. To switch between tmux windows, use Ctrl-B then n to move to the next window, or Ctrl-B then p to move to the previous window.

  3. To rename a tmux window, press Ctrl-B then , (comma). Enter the desired name and press Enter.

Renaming tmux sessions

  1. Start tmux with a meaningful session name by typing tmux new -s <session_name> (Replace <session_name> with the desired name).

  2. To rename an existing tmux session, detach from the session, then type tmux rename-session -t <old_session_name> <new_session_name> (Replace <old_session_name> with the current session name and <new_session_name> with the desired new name).

  3. Reattach to the renamed session: tmux attach -t <new_session_name>.

By using tmux, you can manage multiple terminal sessions with a single terminal window, protect your remote connections from accidental disconnections, and start long-running jobs on a remote system, then disconnect and come back later to see the results.

Last updated