Quite simply, tmux allows you to run multiple terminal command lines at the same time side by side much like putting multiple windows next to each other so you see both simultaneously. It stands for “terminal multiplexer”, a fancy term for something so logical. Here are the basics to get you started with tmux quickly.
First of all, just run tmux. You will very likely have it in your system no matter which Linux or UNIX distribution you’re using. Otherwise you can get it from the tmux website. For MacOS, I suggest using brew package manager.
And you’re in. Not much has changed, but you should see the green bar at the bottom, which is the tmux status bar showing you which window you’re in, date and time, and the hostname of your system. The goodness is in the keyboard commands that you can now use to split the current window into multiple panes, or to create new windows with their own panes. You can then switch between panes and windows with ease.
The way keyboard commands work is by first pressing a shortcut CTRL-B, and then entering a character corresponding to a command. For example, to split the current window or pane into two vertical panes press CTRL-B %. Just press CTRL-B together, then enter the % normally, and it will split.
Here are a few of the basic commands that will have you up and going with tmux with ease:
With these shortcuts you can create as many panes and windows as you need, and switch between them.
One more thing though. These sets of windows and panes are known as tmux sessions, and you can actually have multiple of them, and they are saved on the system so that they can be attached to different terminals you can in from.
You can detach from the current session with CTRL-B d, and you’ll end up back on the normal bare command line. Then you can run this to list all of the sessions with its numbers:
You’ll see something like:
Then you can attach to session 0, for example, with this command:
And if you no longer want a particular session you can kill it:
You can see the full breakdown of sessions, their windows, and their panes by issuing this command:
Other useful commands with more information: