This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has sudo access and that you precede each of the privileged commands with sudo


tmux is a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. Each window occupies the entire screen and can be split into rectangular panes.

tmux includes most features of GNU Screen. It allows users to start a terminal session with clients that are not bound to a specific physical or virtual console; multiple terminal sessions can be created within a single terminal session and then freely rebound from one virtual console to another, and each session can have several connected clients.

tmux sessions are persistent which means that programs running in Tmux will continue to run even if you get disconnected.

All commands in Tmux start with a prefix, which by default is ctrl+b.

Installing tmux

You can follow the instructions given below to install the tmux on your system

On Debian Based Systems

Run the following command to install tmux on your debian based system e.g. Ubuntu.

[email protected]:~$ apt install tmux

On Red-Hat Based Systems

Run the following command to install tmux on your red-hat based system e.g. CentOS and Fedora.

[email protected]:~$ yum install tmux

On MacOS

Run the fllowing command to install tmux on your MacOS

[email protected]:~$ brew install tmux

If you don’t have Homebrew installed yet, open either Terminal or iTerm and paste the below command:

/usr/bin/ruby -e "$(curl -fsSL"

Starting A tmux Session

To start a new session in tmux, simply type following command in your terminal.

[email protected]:~$ tmux new -s name-of-session

If you invoke tmux by itself, you’ll get dropped into a new session. And if you exit this session, you drop right back into your normal shell.

Detaching From A Session

To detach from a session you invoke the shortcut ctrl-b followed by d, for detatch, or by typing detach explicitly.

[email protected]:~$ tmux detach

Using Prefix With tmux

All commands in tmux require the prefix shortcut, which by default is ctrl+b. After entering ctrl+b you can then run a tmux command, or type : to get a tmux prompt.

Displaying Sessions In tmux

If you want to display all the existing sessions in tmux, you can use the following command

[email protected]:~$ tmux ls

Connecting To An Existing Session

If you want to connect to an existing session, you can use the following command

[email protected]:~$  tmux attach -t session-ID

[email protected]:~$  tmux attach -t 1

Killing An Existing Session

If you want to kill an existing session, you can run the following command

[email protected]:~$ tmux kill-session -t session-name

[email protected]:~$ tmux kill-session -t 1

Changing Name Of A Session

If you want to change the name of a session, you can use the following command

[email protected]:~$ tmux a -t name-of-session

Managing Windows And Panes

Below are some most common commands for managing tmux windows and panes:

  • Ctrl+b c Create a new window (with shell)
  • Ctrl+b w Choose window from a list
  • Ctrl+b 0 Switch to window 0 (by number )
  • Ctrl+b , Rename the current window
  • Ctrl+b % Split current pane horizontally into two panes
  • Ctrl+b " Split current pane vertically into two panes
  • Ctrl+b o Go to the next pane
  • Ctrl+b ; Toggle between the current and previous pane
  • Ctrl+b x Close the current pane

Managing Sessions

Below are some most common commands for managing tmux sessions:

  • s list sessions
  • $ rename the current session
  • d detach from the current session

Customizing tmux

Customizing tmux is done primarily through the .tmux.conf file.

Simply pick the one theme you want and copy the config into ~/.tmux.conf and then source it with tmux source-file ~/.tmux.conf.