Tmux
How to use tmux
Start tmux by typing
tmuxin your terminal. This creates a new session and attaches to it.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).Detach from your tmux session by pressing
Ctrl+BthenD.List active tmux sessions with
tmux ls.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 thetmux lscommand).
Switching between tmux windows and creating new ones
To create a new tmux window, press
Ctrl-Bthenc.To switch between tmux windows, use
Ctrl-Bthennto move to the next window, orCtrl-Bthenpto move to the previous window.To rename a tmux window, press
Ctrl-Bthen,(comma). Enter the desired name and press Enter.
Renaming tmux sessions
Start tmux with a meaningful session name by typing
tmux new -s <session_name>(Replace<session_name>with the desired name).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).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