With the terminal mul­ti­plex­er tmux, you use mul­ti­task­ing with command lines from your chosen Linux dis­tri­bu­tion. tmux can be used to create, edit, separate or merge several sessions sim­ul­tan­eously in one terminal.

The operating system Linux is one of the most popular dis­tri­bu­tions alongside Windows and macOS. It’s open source and therefore free to use. Control and ad­min­is­tra­tion of one of the many Linux dis­tri­bu­tions such as Ubuntu, Debian or Linux Mint is often carried out using the command line or via the terminal and Linux commands. In order to use, manage and configure console sessions in a terminal sim­ul­tan­eously, terminal mul­ti­plex­ers such as GNU Screen or tmux are used.

Web hosting
The hosting your website deserves at an un­beat­able price
  • Loading 3x faster for happier customers
  • Rock-solid 99.99% uptime and advanced pro­tec­tion
  • Only at IONOS: up to 500 GB included

What is tmux?

The open-source terminal mul­ti­plex­er tmux was developed by Nicholas Marriott and was first released in 2007. Func­tion­ally, tmux is similar to the terminal mul­ti­plex­er GNU Screen, in that both give you the ability to work with multiple console windows in a terminal session and split them into separate panes while writing a shell script. In this way, you can even col­lab­or­ate with others in parallel, ideally via Secure Shell (SSH) in remote sessions.

With tmux, you enter commands to control and edit your Linux dis­tri­bu­tion. These include, for example, commands for the as­sign­ment of directory rights with chmod or the “shutdown -h” command for a simple Linux shutdown. You can use tmux in Ubuntu, Debian, or other Linux dis­tri­bu­tions without any problems. In Windows tmux can only be used via WSL or WSL2 (Windows subsystem for Windows 2). With WSL2, you can also use Linux ap­plic­a­tions and Linux tools in Windows.

Tip

Are you looking for the right hosting partner for your Linux projects? Then consider using Linux hosting from IONOS with flexible rates, flexible scalable per­form­ance, SSL, DDoS pro­tec­tion and HTTP/2.

How to operate tmux

After being installed through official Linux package sources, tmux can easily be started via the terminal using the command “tmux”. The terminal mul­ti­plex­er is operated through a typical terminal. The re­quire­ments for in­stalling tmux are:

  • Linux dis­tri­bu­tion or a Linux-based system
  • User profile with root rights
  • Access to terminal and command line commands / key shortcuts

The most important con­sid­er­a­tions when operating tmux are terminal sessions, windows and panels:

  • Terminal sessions: In terminal sessions, you execute tasks and commands and operate your Linux dis­tri­bu­tion.
  • Windows: If you want to execute specific tasks sep­ar­ately within a session, tmux allows you to work with several windows sim­ul­tan­eously in one session.
  • Panes: You can also divide these windows into different areas (“panes”), e.g., to run error logs while you perform other tasks in the same window.

Commands and keyboard shortcuts are used to operate tmux, the most important of which are listed below.

tmux commands

Install tmux on Linux using the official Linux package manager:

apt-get install tmux

Install tmux on Ubuntu and Debian:

sudo apt-get install tmux

Start tmux

tmux

Start and name a new tmux session

tmux new -s [session name]

End a tmux session

exit

Reconnect to the last tmux session

tmux a -t [session name]

or

tmux a #

Show all tmux sessions (show session name and number of open windows)

tmux 1s

Adjusting panes with [Ctrl] + [B] + [:] and resize pane

If you divide a window into panes, you have the option of con­fig­ur­ing the panes as you wish. To do so, first press the key com­bin­a­tion [Ctrl] + [B] + [:]. You can now customize the panes using the following commands:

  • Resize pane -D: Move the dividing line between panes downwards
  • Resize pane -U: Move the dividing line between panes upwards
  • Resize pane -R: Move the dividing line between panes to the right
  • Resize pane -L: Move the dividing line between panes to the left

You can also move the dividing line around pre­defined cells as follows. However, this affects all panes in the window:

  • Resize pane -U 10: Move the dividing line 10 cells upwards
  • Resize pane -t 2 -R 5: Move the dividing line 5 cells to the right

Maximize and minimize pane (pre­vi­ously the key com­bin­a­tion [Ctrl] + [B] + [:])

resize-pane -Z

Detach from existing session (with session name if necessary)

tmux detach

Attach to existing session (with session name if necessary)

tmux attach

tmux key com­bin­a­tions

As well as control and execution using commands and scripts, tmux is also operated by keyboard shortcuts. To initiate control using keyboard shortcuts, press [Ctrl] + [B]. All sub­sequent entries will produce the desired results. The most important shortcuts include:

Session commands:

    • S: Display all sessions and switch between sessions
    • $: Rename current session
    • D: Detach existing session and move to back­ground
    • ?: Display currently active keyboard shortcuts (open help area)

Window commands:

    • C: Create / open new window
    • W: List all currently existing windows, switch between windows
    • L: Switch to the last used window
    • P: Switch to previous chro­no­lo­gic­al window
    • N: Switch to next chro­no­lo­gic­al window
    • ,: Rename current window
    • &: Exit current window (confirm with “Y”)
    • 1, 2, 3, (...): Jump to window number X
    • [: Use scroll mode (scroll with arrow keys in current window)

Pane commands:

    • X: Close current pane
    • %: Split current pane ver­tic­ally (second pane is created in the window)
    • ": Split current pane ho­ri­zont­ally (second pane is created in the window)
    • Arrow keys (left, right, up, down): Navigate between panes
    • H: Jump to left pane
    • I: Jump to right pane
    • J: Jump to bottom pane
    • K: Jump to top pane
    • Q: Show number of panes
    • O: Navigate chro­no­lo­gic­ally through all panes
    • }: Swap current pane with the next one
    • {: Swap current pane with the preceding one
    • Space bar: Switch between the pane divisions
    • !: Detach current pane and open it in a new window

Short tutorial on in­stalling and using tmux

Follow these steps to install and use tmux:

Step 1: Install the terminal mul­ti­plex­er from official Linux package sources using the install package command: apt-get install tmux

With Debian or Ubuntu, you’ll have to use the “sudo” add-on: sudo apt-get install tmux

Step 2: Start tmux by typing “tmux” into the terminal. When tmux starts, you’ll see a status display on the bottom of the window con­sist­ing of the host name (username@host-server), the time and the date. On the bottom left, you’ll see the name of the session (if named) and the number of windows in the following format “[0] 0:bash*”. The first window is named “0”. If there is a process running in the window, it is displayed after the 0 (e.g., “0:bash*”).

Step 3: Control tmux by using commands and keyboard shortcuts. Initiate each command or keyboard shortcut with [Ctrl] + [B] or, when con­fig­ur­ing panes, [Ctrl] + [B] + [:] to get tmux’s attention.

Step 4: Start a new named session by using the command “tmux new -s”. After “-s”, enter the desired name of the session. If you want to start a session without a session name, simply type “tmux”.

Step 5: To end a session, enter the command “exit” or use the keyboard shortcut [Ctrl] + [D].

Step 6: To open a new window in the session, press [C]. To start a second session in parallel with the first, use the command “tmux new -s [session name].” again. The status display un­der­neath shows which session you are currently in.

Step 7: If you want to divide a window into panes, press [%] for a ver­tic­ally divided window or ["] for a ho­ri­zont­ally divided window. Use the arrow keys to navigate between the panes.

Step 8: If you want to detach a running session but keep processes running, use the “tmux detach” command. The session and the running processes will continue to run in the back­ground. To resume the session, use the “tmux attach” command to reconnect.

What can tmux be used for?

Just like the terminal mul­ti­plex­er GNU Screen, tmux offers you the chance to work in multiple sessions and windows in a Linux dis­tri­bu­tion terminal, as well as to split and configure windows into multiple areas for mul­ti­task­ing.

This way, you can run parallel processes and programs and execute different tmux commands at the same time. Sim­ul­tan­eous remote sessions and col­lab­or­a­tions with multiple users are also possible. You can also quit processes and sessions, move them to the back­ground, and pick up where you left off later.

Tip

Do you need full vir­tu­al­iz­a­tion and optimal VPS per­form­ance? Then use the vServer from IONOS with 100% SSD SAN storage for demanding projects, with scalable and dedicated resources and optional Plesk web hosting.

How tmux differs from GNU Screen

At first glance, GNU Screen and tmux work in exactly the same way and offer the same important functions. For example, you initiate commands and keyboard shortcuts in GNU Screen with [Ctrl] + [A] instead of [Ctrl] + [B]. One major dif­fer­ence, however, is that GNU Screen does not auto­mat­ic­ally display a status indicator with the name of the current session at the bottom of the window. If you want a status display in GNU Screen, you have to configure it manually.

The un­com­plic­ated naming and renaming of sessions and windows also makes it easier to keep track of and navigate between windows and sessions in tmux. In addition, unlike GNU Screen, there’s no risk of losing a window com­pletely if you detach it and move it to the back­ground in tmux. Windows can easily be retrieved using a command line command, or an overview of all current windows can be accessed.

Tip

Use the scalable computing power of virtual machines for a powerful virtual in­fra­struc­ture. The cloud server from IONOS offers 100% dedicated resources, root access, cloud panel and secure data centers for your project.

Is tmux worth it?

Whether it’s the renaming of windows and sessions or the helpful status and session in­dic­at­ors at the bottom of the window, many users find tmux clearer and more user-friendly than GNU Screen. If you work with several processes and programs in the terminal at the same time and rely on simple, efficient mul­ti­task­ing, tmux will prove to be a useful and worth­while terminal mul­ti­plex­er. And a free one at that.

Go to Main Menu