Home Terminal multiplexersWhy I Use Tmux and GNU Screen Locally, Even Though My Terminal Emulator Has Tabs and Splits

Why I Use Tmux and GNU Screen Locally, Even Though My Terminal Emulator Has Tabs and Splits

By sk
1 views 11 mins read

Most experienced users use the terminal multiplexers such as Tmux or GNU screen to work with remote Linux servers. These tools keep terminal sessions alive even when an SSH connection drops. You can disconnect, reconnect later, and continue where you left off.

That is probably their most well-known use case.

But I use tmux on my local Linux desktop every day, too. In fact, I find it hard to work without it.

At first, using a terminal multiplexer locally might seem unnecessary. Modern terminal emulators already support tabs, split panes, keyboard shortcuts, and sometimes session restoration. Why add another tool that appears to do the same thing?

After using Linux for a long time, I have found many good reasons to use tmux and screen locally. Some are obvious, while others become clear only after you make it part of your daily workflow.

Let's look at them.

1. Your Terminal Sessions Survive Terminal Emulator Crashes and Restarts

This is one of the simplest reasons to use tmux or screen on your local machine.

Imagine that you are compiling a large project. You have also started a development server, opened a REPL, and are running a few other commands in separate terminal panes.

Now imagine accidentally closing your terminal emulator.

Without a terminal multiplexer, you might lose those running processes along with their terminal sessions.

With tmux, things work differently.

The tmux server runs independently of the terminal emulator. Your terminal emulator is only a client that connects to it.

You can close the terminal emulator, open another one, and attach to your existing tmux session:

tmux attach

Your running processes, windows, panes, and retained scrollback history remain available.

This is also useful when you restart your graphical desktop environment.

For example, restarting Wayland or Xorg terminates or disconnects graphical terminal clients. But the tmux server can continue running independently of those clients.

After logging back into your desktop, simply open a terminal and attach to your previous session.

Your compilation or other long-running command can continue without interruption.

Of course, this depends on how your Linux system manages user processes. A machine reboot, a killed tmux server, or an unexpected process termination can still end your session.

2. You Can Access Your Local Terminal Sessions Remotely

This is probably the feature that convinced me to use tmux locally in the first place.

I can leave a tmux session running on my desktop and access it from another computer.

For example, suppose I am working on my desktop and need to leave for a while. I can simply leave my tmux session running.

Later, I can SSH into that desktop from my laptop and attach to the same session:

ssh desktop
tmux attach

I get the same windows, panes, running jobs, and retained scrollback history.

I don't need to restart my development environment or reconstruct my workspace.

It is almost like having a remote desktop for my terminal, except that the actual programs continue running on the original machine.

This is especially useful when moving between a desktop and a laptop, or when you want to access your home development machine while travelling.

There is one important distinction: attaching from another computer gives you access to the existing terminal session. It does not move the running processes to your laptop. They continue running on the desktop.

Related Read: Reptyr: Move a Running Process from One Terminal to Another Without Closing It

3. Your Terminal Workflow is Independent of the Terminal Emulator

I don't want my terminal workflow to depend on a particular terminal emulator.

I might use one terminal emulator today and another one tomorrow. I might occasionally need to use a basic terminal such as xterm.

That shouldn't force me to change how I organize my terminal sessions.

Tmux provides its own session, window, and pane management. The terminal emulator simply displays the terminal interface.

This separation is useful because terminal emulators do not all implement the same features.

Some have excellent split-pane support. Others have better tab management. Some provide session restoration, while others offer very little in this area.

With tmux, I get a consistent experience regardless of which terminal emulator I use.

In fact, whenever I open xterm for some reason, the first thing I do is start a named tmux session.

Recommended Read:Autostart Tmux Session On Remote System When Logging In Via SSH

4. Tmux Offers More than Terminal Tabs and Split Panes

Most modern terminal emulators support tabs and split panes. So, at first glance, tmux might look like an unnecessary duplicate.

But tmux offers much more than arranging terminal windows.

It provides a complete terminal workspace with several useful features:

  • Sessions: Keep separate working environments for different tasks or projects.
  • Windows: Organize multiple terminal workspaces inside a session.
  • Panes: Split a window into multiple terminal areas.
  • Layouts: Arrange panes in different configurations.
  • Scrollback: Retain terminal output independently of the terminal emulator.
  • Copy mode: Navigate, search, select, and copy terminal output using keyboard shortcuts.
  • Session management: Detach, reattach, create, and switch between sessions.
  • Scripting: Create and configure entire terminal workspaces using shell scripts.

The important difference is that these features work together.

For example, I can create separate sessions for different projects, organize each project into multiple windows, and split those windows into panes.

I can also move panes between windows, switch layouts, and zoom into a single pane without losing the others.

Once you become comfortable with this workflow, ordinary terminal tabs can feel quite limited.

5. You Can Automate Your Development Environment

Another advantage of tmux is its command-line interface.

You can create sessions, windows, panes, and layouts using shell commands. This makes it possible to automate your entire terminal workspace.

For example, imagine that you regularly work on a project that needs three terminal panes:

  1. One pane for your editor.
  2. One pane for the development server.
  3. One pane for running tests.

You can create this environment automatically:

#!/usr/bin/env bash

SESSION="myproject"
PROJECT="$HOME/projects/myproject"

# Create the session if it does not already exist
if ! tmux has-session -t "$SESSION" 2>/dev/null; then
tmux new-session -d -s "$SESSION" -c "$PROJECT"

# Start the editor
tmux send-keys -t "$SESSION" "nvim ." C-m

# Create a pane for the development server
tmux split-window -h -t "$SESSION" -c "$PROJECT"
tmux send-keys -t "$SESSION" "npm run dev" C-m

# Create another pane for tests
tmux split-window -v -t "$SESSION" -c "$PROJECT"
tmux send-keys -t "$SESSION" "npm test -- --watch" C-m
fi

# Attach to the session
tmux attach-session -t "$SESSION"

Now you can launch your entire development environment with one command.

You can create similar scripts for different projects and workflows.

This is much more flexible than manually opening terminal tabs and arranging split panes every time you start working.

6. Run Background Processes without Losing their Console Output

Sometimes I want to keep a process running in the background, but I don't want to turn it into a traditional daemon.

I still want to see its console messages. I might also need to interact with it or stop it manually.

Tmux makes this easy.

I can start a script inside a tmux session, detach from the session, and let the script continue running.

Later, I can reattach and inspect its output.

This is useful for long-running scripts, development servers, monitoring commands, and other programs that do not provide a convenient daemon mode.

It is also useful when a program has a daemon mode but its logging is incomplete. Sometimes the console displays useful diagnostic messages that never make it into the log files.

Being able to reattach to the original terminal is a convenient troubleshooting tool.

A Practical Example: Running a Script on a Public Kiosk

At work, I have used GNU Screen on my machines to keep a shell script running at boot.

These machines were public kiosks. We did not want visitors, especially children, to exit our application and access the rest of the desktop.

The script checked which application was currently in focus and restarted our application if it was no longer in the foreground.

Sometimes, we needed to exit the application and use the graphical desktop for maintenance.

We could SSH into the machine, attach to the existing Screen session, and stop the script.

We didn't need to kill the entire graphical session or restart the machine.

For example, Screen can start a named session in detached mode:

screen -dmS kiosk-guard /path/to/watchdog.sh

Later, we could reconnect to it:

screen -r kiosk-guard

Our newer exhibits run Debian and no longer need this workaround, but it was a practical example of how useful a persistent terminal session can be.

For production Linux services, I would generally prefer systemd for process supervision, startup management, and restart policies, with journald for logging.

But tools like tmux and Screen remain useful when I need direct access to a running process and its terminal output.

7. Use Tmux for Both Local and Remote Work

One of the nicest things about tmux is that the same workflow works on your desktop and remote servers.

I use local tmux to organize my everyday terminal work. When I SSH into a remote Linux server, I can start or attach to another tmux session there.

This creates one small problem: nested tmux sessions.

By default, both sessions use Ctrl-b as their prefix key.

If you attach to a remote tmux session from inside a local tmux session, you may find yourself pressing Ctrl-b twice to send the prefix to the inner session.

That gets annoying quickly.

One solution is to use different prefix keys for local and remote tmux sessions. However, changing the prefix alone does not automatically forward the remote prefix through the local session. You also need to configure the outer tmux to send it.

For example, keep Ctrl-b as the local prefix and use Ctrl-a remotely.

Local **~/.tmux.conf**:

set -g prefix C-b

# Forward Ctrl-a to the active pane when used after Ctrl-b
bind-key C-a send-keys C-a

Remote **~/.tmux.conf**:

set -g prefix C-a
unbind C-b
bind C-a send-prefix

Now, when working inside the local tmux session, press Ctrl-b, followed by Ctrl-a, to send the remote prefix to the inner session.

This makes nested tmux sessions much easier to manage.

8. When Do You Actually Need Tmux Locally?

Of course, not everyone needs tmux.

If your typical workflow involves opening a terminal, running a few commands, and closing it when you are done, your terminal emulator is probably enough.

Modern terminal emulators such as Kitty, WezTerm, and Ghostty already provide excellent tab and pane management.

You don't need tmux just because you use Linux or work with remote servers.

But tmux is particularly useful when you want:

  • Terminal sessions that survive terminal emulator restarts.
  • Long-running commands that continue after you close your terminal.
  • Access to your desktop's terminal sessions over SSH.
  • A consistent terminal workflow across different terminal emulators.
  • Scriptable development environments.
  • Better session, window, and pane management.
  • Direct access to running processes for troubleshooting.

There is also no need to choose between tmux and your terminal emulator. They complement each other.

I use terminal emulator tabs when I want separate SSH connections, while tmux handles the actual terminal workspace inside each connection.

Conclusion

Personally, I see tmux as much more than a tool for keeping SSH sessions alive.

For me, it is a persistent terminal workspace manager.

It protects my running jobs from accidental terminal closure, lets me access my desktop sessions remotely, provides consistent terminal management across different emulators, and makes it easy to automate my development environment.

Most importantly, it separates terminal session management from the graphical terminal application.

That separation is useful even when working entirely on a local Linux machine.

If you have only used tmux on remote servers, I recommend trying it as your everyday local terminal multiplexer. You might find, as I did, that you no longer want to work without it.

Suggested Read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More