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 tmux window, you can use the tmux command followed by any command you want to run. For example:

    tmux ls
    

    This will open a new tmux window and run the ls command 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 d key combination. This will close the terminal window and return you to the command prompt, but the program or process you were running within the tmux window 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 the tmux -ls command. This will display a list of all the tmux windows 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 attach command followed by the session name or process ID of the session you want to reattach to. For example:

    tmux attach -t 12345
    

    This 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.

The text above is licensed under CC BY-SA 4.0 CC BY SA