Getting Started with tmux - A Beginners Guide

Learn how to install, configure, and use tmux to boost your terminal productivity with sessions, windows, and panes.
Author

David Gwyer

Published

July 14, 2025

If you have ever lost your work due to an unexpected terminal closure, or found yourself managing multiple terminal windows inefficiently, then you might be interested in tmux (terminal multiplexer). It’s a robust tool that creates persistent terminal sessions, allowing you to organize and manage multiple command-line environments within a single interface.

It enables you to split your terminal into multiple panes, create separate workspaces for different projects, and maintain session continuity even when disconnecting from your work. For developers managing multiple processes, system administrators coordinating various tasks, or anyone seeking to optimize their terminal workflow, tmux provides a structured approach to command-line productivity.

This introductory guide explores the basics of tmux core functionality through some practical examples to help you get started with this powerful tool. We’ll cover the following topics, the keyboard shortcuts are also included for future reference:

tmux Feature Commands
Sessions tmux new -s name, tmux ls, tmux attach, tmux kill-session
Detach/Attach Ctrl+b d (detach), tmux attach -t name
Windows Ctrl+b c (new window), Ctrl+b n/p (next/prev)
Panes Ctrl+b " (split horizontal), % (split vertical), arrow keys to move
Layouts Ctrl+b space to cycle layouts
Resizing Ctrl+b then hold Alt (or Ctrl) and arrow keys
Scrolling Ctrl+b [ to enter copy mode, use arrows or PgUp

What is tmux and Why Should You Care?

As mentioned above, tmux is a powerful tool that lets you run multiple terminal sessions inside a single terminal window. Think of it as having multiple desktops for your command line work - you can create, organize, and switch between different terminal environments seamlessly.

The real magic happens when you realize tmux sessions persist even when you disconnect from your machine. This means you can start a long-running process, detach from it, close your laptop, and come back later to find everything exactly as you left it! tmux has become indispensable for developers and system administrators. Here are the main highlights:

  1. Session persistence - Your work survives network disconnections
  2. Organization - Keep different projects in separate sessions
  3. Efficiency - Switch between tasks without losing context
  4. Remote work - Perfect for SSH sessions to servers

Understanding Terminal Processes

Before diving into tmux commands it’s worth reviewing a little about how processes work.

What’s a process? Every terminal command you run creates a process. When you type ls for instance, Linux creates a process to list files, then it ends.

Foreground vs Background There are two main types of process:

  • Foreground: The process you’re currently interacting with (blocks your terminal)
  • Background: Processes that run “behind the scenes” (your terminal stays free)

Here’s a simple example to try:

sleep 10

This will block your terminal for 10 seconds. Now try:

sleep 10 &

The & runs the process in the background - your terminal is immediately free again.

When you run sleep 10 & it returns a procees ID. Here is some sample output to demonstrate:

$: ps
  PID TTY          TIME CMD
92747 pts/27   00:00:00 bash
97598 pts/27   00:00:00 ps
$: sleep 10 &
[1] 97671
$: ps
  PID TTY          TIME CMD
92747 pts/27   00:00:00 bash
97671 pts/27   00:00:00 sleep
97690 pts/27   00:00:00 ps
$: ps
  PID TTY          TIME CMD
92747 pts/27   00:00:00 bash
97893 pts/27   00:00:00 ps
[1]+  Done                    sleep 10

The number 97671 is the Process ID (PID) - think of it as a unique identifier for that running process.

Notice how in the ps output: (ps displays current active processes)

  • First ps: Only bash and ps itself
  • After sleep 10 &: Now you see the sleep process with PID 97671
  • Final ps: The sleep process is gone, and you see [1]+ Done sleep 10

The [1] is the “job number” - your shell keeps track of background jobs with these numbers.

Key insight: When you run a command normally, if you close your terminal, the process dies with it. But what if you want a process to keep running even after you disconnect? This is where tmux shines! Instead of your processes being tied to your terminal session, they live inside tmux sessions that persist independently.

You may be interested to know that normal processes are not accessible between terminal sessions. If you run the command sleep 90 & which returns process ID such as 99697, and then opened another terminal and ran ps you won’t find that process was listed. This is because of process isolation between terminal sessions. Each terminal session (TTY) has its own process tree. When you run sleep 90 & in one terminal, it becomes a child process of that specific terminal’s shell. Other terminals can’t see it because they’re separate process trees.

You can verify this by running:

ps aux | grep sleep

This shows ALL sleep processes on the system, regardless of which terminal started them.

This is exactly why tmux is so powerful! Instead of processes being tied to individual terminal windows, tmux creates a persistent session that can be shared and accessed from anywhere.

To clarify, when you open a Linux terminal in the usual way (i.e. not via tmux) then it begins an independent session that acts as a child-process container, separate from all other terminal sessions. This is because each terminal window creates its own independent shell process (like bash), and any commands you run become child processes of that shell.

When you close the terminal window, the shell process ends, and all its child processes get terminated too. This is the sleep 90 & process above disappeared when a new terminal was opened - it belonged to the first terminal’s shell process tree only.

tmux changes this by creating a persistent session that exists independently of any particular terminal window. The processes run inside tmux’s session, not directly under your terminal’s shell.

When you run a command without &, it’s still a child process of your shell, but it runs in the foreground. This means:

  • The shell waits for it to complete
  • Your terminal is “blocked” - you can’t type new commands
  • The process has control of your terminal’s input/output

With &, the process runs in the background:

  • The shell doesn’t wait for it
  • Your terminal stays free for new commands
  • The process runs independently

So sleep 10 (foreground) blocks your terminal for 10 seconds, while sleep 10 & (background) returns control immediately.

Verifying tmux Installation

Lets get started with some tmux commands now. First we’ll confirm tmux it’s installed and available for use. Try entering tmux -V in the terminal. You should see something like:

~$ tmux -V
tmux 3.2a

This should be a formality, as tmux is already installed by default on a lot of platforms. If for any reason it isn’t available then you’ll need to refer to the official docs for installed instructions for your specific platform.

Sessions: The Foundation of tmux

If tmux is installed you can go ahead and create your first session:

tmux new-session -s myblog

The -s flag allows you to name your session; if you omit this then a name will be auto-assigned.

You can easily tell if tmux is running as you’ll see a green status bar at the bottom with [myblog] showing your session name. Once you’re in the tmux session everything you do here will persist even if you close this terminal window.

Note: You can also use the shorter tmux new -s myblog if you prefer, as new is an alias of new-session.

Try running a simple command to test this persistent behaviour:

echo "I'm inside tmux!"

If you were to just enter exit then this would destroy the tmux instance and return you back to the main terminal, but we don’t want to do that. Instead we’ll ‘detach’ from the tmux terminal in order to make sure it’s still running in the background.

Press this key combination: Ctrl+b, then d (Hold Ctrl and b together, release both, then press d).

As soon as you detach from tmux you’ll be returned to the main terminal (that you atteched from) with a message like this:

~$ tmux new -s myblog
[detached (from session myblog)]

You can view all current tmux session using:

tmux list-sessions

Or the shorthand version:

tmux ls

So far we have just the one tmux session:

~$ tmux ls
myblog: 1 windows (created Mon Jul 14 12:28:42 2025)

To reconnect to our previous tmux session attach to it with:

tmux attach -t myblog

And you should see the green bar again at the bottom or the terminal window indicating tmux is avtive. Not only that, the previous echo command is there too!

Note: By the way, if you to create a new session with the same name (myblog), tmux will give you an error because session names must be unique. You’d need to either:

  • Use a different name: tmux new-session -s myblog2
  • Or attach to the existing session instead

What you just experienced is one of tmux’s most important features. Your session continued running even when you weren’t connected to it. Any processes you had started would still be running.

Let’s practice this cycle once more with a long-running process. Try:

ping google.com

This will continuously ping Google. Once it starts running, detach again with Ctrl+b, d. Wait a few seconds and then reattach. You should see the ping command still running and outputting information to the terminal.

To stop the ping, press Ctrl+c inside the tmux session.

Removing a tmux Session

You can remove (or kill) any tmux session with:

tmux kill-session -t mysession

This is handy to clean up sessions that are no longer required.

tmux Windows: Multiple Terminals in One Session

You can think of tmux windows being a little like tabs in a web browser. Each window is a separate terminal environment within your tmux session. First, make sure you’re inside your tmux session (you should see the green bar). Then create a new window:

Ctrl+b, then c

It may look like the terminal has been reset but if you look in the status bar you’ll notice two bash instances, one with a star. This indicates that the tmux session now has two windows:

[myblog] 0:bash 1:bash*

The numbers (0, 1) are window numbers, and the * indicates which window is currently active.

You can easily switch between windows:

Ctrl+b, then n

This moves to the next window. Similarly, you can also do:

Ctrl+b, then p

This goes to the previous window.

You can create more windows by pressing Ctrl+b, then c. Try adding this to each window to make it easier to recognise when navigating forwards or backwrds between windows:

echo "I'm in window $(tmux display-message -p '#I')"

This will output the current window number:

~$ echo "I'm in window $(tmux display-message -p '#I')"
I'm in window 1

You can also jump directly to a specific window. For example:

Ctrl+b, then 2

This takes you straight to window 2. Try jumping to different windows using their numbers.

tmux Panels

Now let’s explore something even more powerful. Splitting windows into panes.

From any window, try:

Ctrl+b, then "

(That’s Ctrl+b, then the quote character)

This splits the current window horizontally into two panels so we have two stacked views of the current tmux window.

To split the new panel (which is now the active one) press:

Ctrl+b, then %

You should now have something like this:

You now have multiple panes, some split horizontally and some vertically. You can create quite complex layouts this way. You can also move between panes using:

Ctrl+b, then arrow keys

Try using the up/down (or left/right) arrow keys to switch between panes.

Each panel is its own independent terminal environment. You can run different commands in each pane simultaneously. Try running different commands in each pane to see how they work independently. For example, in one pane try:

top

And in another pane try:

ls -la

Let’s just take a moment to clarify what panes are and how they fit in with the windows we created earlier.

Panes only exist within a ‘single’ window. Each window can have its own independent set of panes.

So if you have 4 windows (0, 1, 2, 3), you could: - Window 0: Split into 3 panes - Window 1: Keep as single pane
- Window 2: Split into 2 panes - Window 3: Split into 4 panes

Each window’s pane layout is completely independent of another. When you switch windows (with Ctrl+b, n or Ctrl+b, 2), you see that window’s specific pane arrangement.

Try switching to a different window now and see if it has the same pane layout, or create some splits in a different window to test this.

tmux Layouts

Hopefully buy now you’re getting the hang of tmux’s structure: Sessions contain Windows, and Windows contain Panes.

Let’s explore tmux layouts next. tmux has preset layouts that automatically arrange your panes. In a window with multiple panes, try:

Ctrl+b, then spacebar

This cycles through different preset layouts. Every time you run the above command tmux switches to a different preset layout. There are 5 different ones in total:

  • even-horizontal
  • even-vertical
  • main-horizontal
  • main-vertical
  • tiled

Each one arranges your panes differently. This is super handy when you have multiple panes and want to quickly reorganize them.

Now let’s try resizing panes manually. First, press:

Ctrl+b, then :

This opens tmux’s command prompt at the bottom. You should see the usual green bar replaced with a yellow bar.

Here, you can type tmux commands directly. Try moving to a pane that has been split vertically and type this command:

resize-pane -R 10

Then press Enter. It resizes the right panel, but by how much? The 10 means 10 character columns. So -R 10 resized the current pane 10 columns to the right.

You can also use: - -L 10 (left) - -U 5 (up) - -D 5 (down)

Try resizing in a different direction. For instance, what command would you use to make the current pane 5 rows taller?

That would be:

resize-pane -U 5

Note: When in the tmux command prompt mode you can use the up/down arrow to access previous commands, just like you can do in a regular terminal window. Editing previous commands can save you having to type out the whole command again!

There’s also a quicker way to resize without using the command prompt. Try:

Ctrl+b, then hold Alt and press arrow keys

This lets you resize panes interactively instead.

Scrolling and Copy Mode in tmux

You might have noticed that normal scrolling doesn’t work in tmux panes. To scroll back through your terminal history, you need to enter “copy mode”:

Ctrl+b, then [

Try this for a pane that has had multiple commands entered (i.e. so you have something to scroll through).

Notice how the current window now has a yellow border rather than green, and there is a numbered block to indicate which line you are currently on.

When in copy mode, you can:

Action Keys
Scroll up/down Arrow keys, or PgUp/PgDn
Move word-by-word Alt+Right / Alt+Left
Start selection Press Space
End selection and copy Press Enter
Exit copy mode without copying Press q

Try scrolling up to see your earlier commands, then press q to exit copy mode.

Managing tmux Sessions

Once you start creating multiple tmux sessions, windows, and panes, you’ll want a quick and simple way to switch between them rather than having to detach the current session, and then reattach another one. Fortunately this is really simple.

You can do most session management from within tmux itself. Try this while you’re still inside your tmux session:

Ctrl+b s

This opens an interactive session/window/panel picker.

You’ll see an interactive tree view of every session running on the tmux server. The first level of the tree lists just the session names; pressing left/right arrows keys collapses or expands a session to reveal its windows and panes. Hitting Enter on a session attaches you to its current window, while Enter on a window jumps straight into that window (shifting sessions for you if necessary).

Because you’re looking at a whole tree, you can also tag multiple sessions/windows with t and then run a command on all tagged items—handy for bulk actions like killing, renaming, or moving them. This is a very powerful feature of tmux!

Summary

Congratulations! You’ve now mastered the essential tmux workflow that will transform how you work with terminals. The core concept is simple yet powerful: tmux creates persistent sessions that survive disconnections, letting you organize your work into windows and panes.

Think of tmux sessions as persistent workspaces. You can create a named session, fill it with your work, detach from it, and return later to find everything exactly as you left it. This is perfect for remote work, long-running processes, and keeping multiple projects organized.