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.
- 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.
- 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>
Install tmux on Macos
brew install tmux
To start tmux after installing, type tmux in the terminal window.
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.
Create Named session in Tmux
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.
Reattach the tmux session
For reattaching the tmux sessions.
First we have to get the list of all running tmux sessions.
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.
cCreate a new window (with shell)
wChoose window from a list
0Switch to window 0 (by number )
,Rename the current window
%Split current pane horizontally into two panes
"Split current pane vertically into two panes
oGo to the next pane
;Toggle between current and previous pane
xClose 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