Most Linux distributions have tmux available in their standard repositories. You can install it using your distribution's package manager.
For Debian-based systems (like Ubuntu), use:
sudo apt-get update
sudo apt-get install tmux
For Red Hat-based systems (like Fedora), use:
sudo dnf install tmux
For Arch Linux-based systems, use:
sudo pacman -S tmux
Basic Usage of tmux
Starting a new session
A tmux session is an instance of tmux that can contain one or more windows. To start a new session, simply type:
tmux
You can also create a named session, which makes it easier to identify later:
tmux new -s mysession
Controlling windows and panes
In tmux, you can have multiple windows open, and each window can contain multiple panes.
- Creating a new window:
Ctrl+b c
- Switching between windows:
Ctrl+b n (next window) Ctrl+b p (previous window)
- Splitting a window into panes:Vertically:
Ctrl+b %
Horizontally:
Ctrl+b "
- Switching between panes:
Ctrl+b o
Exiting a tmux session
You can detach from a tmux session without terminating it, allowing you to return to it later:
Ctrl+b d
To exit a session, simply enter the following command in the command line:
exit
Managing sessions
To see a list of running tmux sessions, use:
tmux ls
To attach to an existing session:
tmux attach -t mysession
tmux offers many more options and customizations that you can explore through the manual page (man tmux
) or online documentation. With tmux, you can easily switch between multiple terminals, sessions, and keep your work organized and efficient.