tmux Command: Tutorial & Examples
Run multiple "tabs" in one terminal session
tmux is a terminal multiplexer for Linux, similar to screen. It allows you to create and manage multiple terminal sessions within a single terminal window
or console, and enables you to run multiple programs or processes in the background while you are logged in to the terminal.
Here are some common uses of the tmux command:
Start a new terminal session: To start a new terminal session within a
tmuxwindow, you can use thetmuxcommand followed by any command you want to run. For example:tmux lsThis will open a new
tmuxwindow and run thelscommand in it.Detach from a terminal session: To detach from a terminal session and leave it running in the background, you can use the
Ctrl-b dkey combination. This will close the terminal window and return you to the command prompt, but the program or process you were running within thetmuxwindow will continue to run in the background.List available terminal sessions: To list all the available terminal sessions that you have running in
tmux, you can use thetmux -lscommand. This will display a list of all thetmuxwindows you have open, along with their session names and process IDs.Reattach to a terminal session: To reattach to a terminal session that you previously detached from, you can use the
tmux attachcommand followed by the session name or process ID of the session you want to reattach to. For example:tmux attach -t 12345This will reattach to the terminal session with the process ID 12345.
There are many more options and features available with the tmux command. You can use the man tmux command to view the full manual for tmux and learn more about how to use
it.
Info: Here at CleverUptime we use tmux a lot to run programs in the background even when we're disconnected from the server. It's also very helpful when your
internet connection is not very stable. When the connection breaks up you can log in again and continue where you left off. As an alternative, we also
use screen but most of us prefer tmux.
Further Reading
- Linux for Hackers by Mark Reed (partner link)
- How Linux Works by Brian Ward (partner link)
- Linux for Beginners by Jason Cannon (partner link)
- Expert Linux Administration Guide by Vishal Rai (partner link)
As an Amazon Associate, I earn from qualifying purchases.