What is Tmux?
For those who do not know what Tmux is, but somehow ended up in this page, it is terminal multiplexer for Unix-like operating systems. This guide will go deeper in Tmux usage and share basic Tmux commands. What does terminal multiplexer mean? It's a piece of software that allows multiple terminal sessions to be accessed simultaneously in a single window. This is very useful for running more than one command-line program at the same time on the remote machine. It's also used for detaching the process from it's controlling terminal. This allows SSH session to remain active without being visible. This terminal multiplexer allows you to:
- Leave terminal sessions and come back without interrupting the running process. On a remote computer, you can run some long installation process, go offline, and come back later to see the results, so you'll have the live terminal output.
- Allow you to manage a whole bunch of screens, split displays, dashboards at once, organized in three layers as sessions, windows, and panes. You can maneuver many terminal screens with simple shortcuts and manipulate your workspace with scripts and hotkeys.
Get Gayle Laakmann - Cracking the Coding Interview - 4th, 5th and 6th edition
Tmux commands
So, let's go to the commonly used Tmux commands:
List sessions
tmux ls
start new session
tmux
start new named session
tmux new -s sessionName
attach to named session
tmux a -t sessionName
kill session
tmux kill-session -t sessionName
kill all tmux sessions
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
detach
ctrl+shif+b and then press d
For more detailed list of commands including those for tabs and splits, check Tmux cheetsheet on GitHub.