GNU Screen and tmux are both terminal multiplexers, but the most surprising truth is that they are fundamentally different in their design philosophy, which leads to drastically different user experiences and capabilities. Screen, the elder statesman, treats your terminal session as a single, monolithic entity that you can detach and reattach. tmux, on the other hand, views your session as a collection of independent windows, each with its own status bar, that you can arrange and manage with granular control.
Let’s see this in action. Imagine you’re SSH’d into a remote server and want to run a long-running process.
With GNU Screen:
$ ssh user@remote-server
user@remote-server's password:
Last login: Tue Oct 26 10:00:00 2023 from 192.168.1.100
user@remote-server:~$ screen
# Now you're in a new screen session. The shell prompt looks the same.
user@remote-server:~$ top
# Let top run...
# To detach, press Ctrl+a, then d
# You'll see "[detached from 12345.pts-0.remote-server]"
user@remote-server:~$ exit
$
Now, disconnect your SSH session. The top command is still running on the remote server. To get back to it:
$ ssh user@remote-server
user@remote-server's password:
Last login: Tue Oct 26 10:05:00 2023 from 192.168.1.100
user@remote-server:~$ screen -r
# You're back in your screen session, and top is still running.
user@remote-server:~$
With tmux:
$ ssh user@remote-server
user@remote-server's password:
Last login: Tue Oct 26 10:00:00 2023 from 192.168.1.100
user@remote-server:~$ tmux
# You'll see a new status bar at the bottom of your terminal.
user@remote-server:~$ top
# Let top run...
# To detach, press Ctrl+b, then d
# You'll see "detached from 12345.pts-0.remote-server"
user@remote-server:~$ exit
$
Disconnect your SSH session. To get back:
$ ssh user@remote-server
user@remote-server's password:
Last login: Tue Oct 26 10:05:00 2023 from 192.168.1.100
user@remote-server:~$ tmux attach
# You're back in your tmux session, and top is still running.
user@remote-server:~$
The core problem both solve is session persistence across disconnections. You can start a process on a remote machine, log out, and log back in to find it still running, exactly where you left off. This is invaluable for unstable network connections or when you need to switch between machines without interrupting your work.
But tmux goes further. Its internal architecture is built around a server-client model. The tmux command you run is a client connecting to a tmux server process. This allows for multiple clients to attach to the same session simultaneously, and it’s the foundation for its more advanced features like window splitting, pane management, and scripting.
Here’s how you might use tmux’s pane splitting:
user@remote-server:~$ tmux
# Press Ctrl+b, then % to split vertically
# Press Ctrl+b, then " to split horizontally
# Now you have multiple panes. You can navigate between them with Ctrl+b, then arrow keys.
# In one pane, run:
user@remote-server:~$ tail -f /var/log/syslog
# In another pane, run:
user@remote-server:~$ htop
This allows you to monitor logs while running system tools, all within a single terminal window. You can even detach from this multi-pane session and reattach later, and it will be exactly as you left it.
The configuration files for both are .screenrc and .tmux.conf, respectively. Both allow extensive customization of key bindings, status bars, and behavior.
Screen’s keybindings are prefixed with Ctrl+a (often abbreviated as C-a). For example, C-a c creates a new window, C-a n goes to the next window, and C-a p goes to the previous window. C-a " lists all windows.
tmux’s keybindings are prefixed with Ctrl+b (often abbreviated as C-b). For example, C-b c creates a new window, C-b n goes to the next window, and C-b p goes to the previous window. C-b w lists all windows. For pane management, C-b % splits vertically, C-b " splits horizontally, and C-b <arrow> navigates between panes.
The most common reason people switch from Screen to tmux is the superior pane management and the ability to have per-window status bars. Screen’s status bar is global, while tmux’s can be customized for each window, providing more context. The client-server architecture also makes tmux more robust and extensible.
The one thing most people don’t realize about tmux’s pane management is that each pane is, in essence, its own independent tmux window. You can even detach a single pane and reattach it as a new, separate tmux session, or promote it to become the primary window of a new session. This level of independence and flexibility is a direct consequence of its client-server design, where each pane is a client process connected to the central tmux server, rather than a simple sub-process within a larger terminal session.
Once you’ve mastered session and pane management, the next logical step is to explore advanced scripting and automation with tmux, leveraging its server-client architecture for complex workflows.