How to Use tmux on Linux for Terminal Multitasking (2025)

Quick Links

  • Installing and Using tmux

  • Multitasking with Panes

  • Tmux Windows

  • Expanding tmux

tmux, short for terminal multiplexer, is a command line utility that makes working from the terminal much easier. It allows you to split your terminal window into many panes, which will persist across multiple SSH sessions.

Installing and Using tmux

tmux can be installed from the package manager for most distros. For Debian-based systems like Ubuntu, that would be:

apt-get install tmux

It's also available on brew, a third-party package manager for macOS, with brew install tmux.

Once it's installed, you can get started by entering the tmuxcommand. However, this starts a session with a random name, so you can create a new named session with tmux new:

tmux new -s [name]

This will take over your terminal window, and you'll see a new command bar at the bottom. You're now running inside tmux, in a newly created session. This session acts as if you opened a new terminal window or a new SSH session and left it running on your desktop, except it's running without a window and behind the scenes. tmuxallows you to connect to it. In essence, tmuxis a desktop environment for the terminal world.

If you close the actual terminal window, this tmux session will persist until you manually terminate it (or restart your system). It works the same way when connecting to a remote server; everything you run will persist until you terminate the session.

To terminate the session, you can run the exitcommand, or press Control+A, Control+D. You'll see "exited" in your main terminal as tmux exits.

More often though, you'll simply want to disconnect from the session and leave it running on the server. To do this, you'll want to press the tmuxprefix shortcut, which is Control+B by default, and then press the "D" key. You'll see "Detached From Session" in your main terminal when tmux exits.

To reconnect to a session, use:

tmux a -t [name]

The "a" command is short for attach-session, which saves some keystrokes. Additionally, you can use the # shortcut to connect to the last created session:

tmux a #

To view all sessions, you can run:

tmux ls

Which will display the session name and current number of windows. Make sure you're not already connected to a tmuxsession when trying to connect to another session, as recursion is blocked by default (and is a pain anyway).

Multitasking with Panes

Panes make heavy use of the tmuxprefix shortcut, so it's best to remember it:

Control+B

Every command will be prefixed with this so that tmuxintercepts it.

To make a new pane, use one of two shortcuts:

  • Control+B %to split vertically
  • Control+B "to split horizontally

These will split the current pane however you choose.

How to Use tmux on Linux for Terminal Multitasking (1)

To switch between panes, you'll have enter Control+B followed by an arrow key. You can also install mouse support with Oh My Tmux!, which will let you click between them.

If you aren't satisfied with how big the panes are, you can resize them with these two commands:

Control+B :

resize-pane -R 4

Control+B followed by a colon opens up the tmuxcommand prompt, which accepts more detailed commands. The command we use here is resize-pane, which takes a direction (U for up, L for left, etc.) and the number of lines to expand. In this case, this command expands the currently selected pane four lines to the right.

Tmux Windows

If you don't like the look of having your terminal split (or just want to multitask will full screen apps) you can use tmuxwindows. You can use the following commands to work with windows:

  • Control+B cto create a new window
  • Control+B pto switch to the previous window
  • Control+B nto switch to the next window
  • Control+B 0-9to switch to a window by index number.

Additionally, pressing Control+B wwill bring up an interactiveexposé, allowing you to view what windows you have open, what commands they are running, and how many panes they have:

How to Use tmux on Linux for Terminal Multitasking (2)

You can terminate a window at any time by using the exitcommand, which will stop all running processes. Note that this will also stop tmuxaltogether if you run it with only one window open.

If the window becomes unresponsive, you can force it closed with Control+B &, which will always kill the running processes in that window.

Expanding tmux

tmuxis wildly popular, and there's plenty of plugins, themes, and community support behind it. Here's a few useful ones:

There is a lot more to tmuxthan is covered here, but the core functionality is relatively simple (which makes it a great utility).

Your changes have been saved

Email is sent

Email has already been sent

Please verify your email address.

You’ve reached your account maximum for followed topics.

Manage Your List

Follow

Followed

Follow with Notifications

Follow

Unfollow

Readers like you help support How-To Geek. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

How to Use tmux on Linux for Terminal Multitasking (2025)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5966

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.