Tmux is a terminal multiplexer which enables a number of terminals to be created, accessed, and controlled from a single screen. Tmux may be detached from a screen and will continue to run in the background, then later re-attached.
Whenever tmux is started it creates a new session with a single window and displays it on screen. A status line at the bottom of the screen shows information on the current session and is used to enter interactive commands.
In this guide, I’m going to share with you Tmux cheat sheet to help you get started with tmux on Linux or Unix box. Before the cheat sheet section, let’s first have a look at how to install tmux on Linux.
How To Install tmux on Linux
We’ll consider installation of Tmux on Arch Linux, Ubuntu, CentOS, Fedora, and Gentoo.
Install tmux on Arch Linux
Just run one of the following commands:
sudo pacman -S tmux --noconfirm
Install tmux on Ubuntu / Debian
To install tmux on Ubuntu or Debian system, use:
sudo apt-get update sudo apt-get install tmux
Install tmux on Fedora / CentOS
For Fedora / CentOS system, use dnf and yum package managers respectively.
# Fedora sudo dnf -y install tmux # CentOS sudo yum -y install tmux
Using tmux on Linux – CentOS, Fedora, Ubuntu, and Debian
After the installation, you can start using tmux. The following tips will give you heads on how to use tmux.
Detach from tmux
To detach from active tmux session, type
control+b followed by
$ ctrl-b d
Restore tmux session
To attach to detached tmux session, use:
$ tmux attach
Create new tmux session with name
Use the new sub-command with -s session to give it a name.
$ tmux new -s test
Attach to named detached tmux session
If you detach tmux session, you can always re-attach using a command with -t option.
$ tmux a -t test
Display tmux sessions
Show all active tmux sessions using the command.
$ tmux ls
The following command is used to rename an active session.
$ Ctrl-b $
Provide session name and press enter key.
Use this key combination to switch session.
$ Ctrl-b s
Show tmux help screen (Q to quit)
Tmux help screen can be checked with:
$ Ctrl-b ?
Press q key to exit.
Tmux Window management
Create a new window.
$ Ctrl-b c
Destroy tmux window:
$ Ctrl-b x
Switch between windows:
$ Ctrl-b [0-9] or Ctrl-b Arrows
Split windows horizontally:
$ Ctrl-b %
Split windows vertically:
$ Ctrl-b "
These are the most common tmux operations and commands you’ll need when working with tmux sessions. If you know of tmux commands not here, you can share on the comments section.