tmux (terminal multiplexer) usage on Linux

Tmux Terminal
2 minutes read

What is TMUX ?

Tmux full form is terminal multiplexer. This may be considered as a window on windows laptop, or a finder window in Mac. However, these are multiple terminal windows on a command line interface.

Tmux is very useful in following cases.

  1. It runs in a detached terminal window from main terminal, hence closure of main window does not effects the processes running in tmux windows. Therefor we can call tmux as persistent terminal.
  2. We can open multiple terminal windows by layering one over the other or even side by side position.

Therefore lets get started by using tmux and enjoy the extended functionalities of terminal window while working on your favourite linux distribution.

Install tmux on Debian, Ubuntu or Raspbian OS

sudo apt-get install tmux

Install tmux on CentOS and Fedora

<pre>yum install tmux</pre>
brew install tmux

Start tmux

To start tmux after installing, type tmux in the terminal window.

tmux

This would launch a new terminal window inside the opened session. To differentiate it from the original window, you would see a status bar in the bottom, indicating that you are in tmux window.

By default tmux sessions are created in ascending numerical digits, However you can give names to your sessions explicitly by the following command.

tmux new -s session_name

Detach the tmux session

Not if you want to come back to your original terminal session, while running the tmux terminal in the background.

Ctrl+b D

Reattach the tmux session

For reattaching the tmux sessions.

First we have to get the list of all running tmux sessions.

tmux ls

Now we can use the name to attach the specified tmux session.

tmux attach-session -t <name>

tmux Windows Management

When we launch tmux session we will see a single window. Additionally we can use multiple panes on a single window by referring the following commands.

  • 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 current and previous pane
  • Ctrl+b x Close the current pane

Therefore by using tmux we can make our life fun while working with terminal sessions. This would also benefit us by increasing our productivity and we can easily multitask in linux.

Reference  – https://github.com/tmux/tmux

Leave a Reply