In a nutshell, tmux is a linux program that allows you to run terminals in the background and reconnect to them later or kill them. This is can be useful for running long scripts, such as updates, over unstable connections.
For example, if you start running updates on a Raspberry Pi from your phone and you lose connection, the Raspberry Pi might stop running the updates or continue without being able to see its progress. If you ran the updates under tmux, you could simply reconnect to the device and reattach to the backgrounded terminal.
This is one of many examples of using tmux. Here is a list of common tmux commands:
sudo apt install tmux
*Installs tmux on Debian-like systems, like Raspbian, Ubuntu, or *tmux
Opens a new tmux shell. Useful for making a safe interactive shelltmux attach
Opens the last used terminal. Useful for quickly opening where you were last working.In tmux: Ctl+b then Ctl+d
Detaches the current terminal. Useful for leaving a terminal running in the background.tmux new-session -s name "command"
Makes a new window called "name" that immediately runs "command". Useful for keeping track of multiple windows.tmux new-session -d -s name "command"
Makes a new session called "name" running "command" and instantly detaches. Useful for writing a script that spawns a background process.tmux ls
Lists active sessions and their names. Useful for viewing active windows and their names or IDs.tmux attach -t name
Reopens the windows with the corresponding name or number. Useful for opening a specific window when you have multiple.
Written with StackEdit.