BWitek.dev
Loading...
Linux

Tmux – A Modern Alternative to Screen

Tmux is a modern terminal multiplexer that lets you manage multiple sessions and windows within a single terminal. Learn how to install Tmux, discover essential commands, and explore practical use cases for server management.

May 22, 2025
274 views
Tmux – A Modern Alternative to Screen

What is Tmux?

Tmux is a modern terminal multiplexer – a tool that lets you create and manage multiple virtual terminals within a single SSH session. This means you can start, for example, a game server, detach from the session, and your server will keep running in the background. Tmux is a great alternative to the popular Screen tool, offering more features and a very convenient workflow.

Installing Tmux

Ubuntu / Debian:

sudo apt update
sudo apt install tmux

CentOS / Fedora:

yum check-update
yum update
sudo yum install tmux

If you're logged in as root, you can skip sudo.

Basic Tmux Commands

Creating a new session

  • tmux - creates a new session and immediately opens a virtual terminal.

  • tmux new -s name - creates a new session with a custom name, e.g. tmux new -s minecraft-server.

Detaching from a session

  • Leave the session running in the background:
    Press Ctrl + B, then D.

  • Close the session:
    Press Ctrl + B, then X, and confirm by typing Y.

Reattaching to an existing session

  • List your sessions:
    tmux ls

  • Attach to a session:
    tmux a -t session_name

Closing all Tmux sessions

tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill

Working with Windows and Panes

With Tmux, you can create multiple windows in a session and split each window into panes.

Most useful shortcuts (always start with Ctrl + B):

Sessions:
:new – new session
s – session list
$ – rename session

Windows:
c – new window
w – window list
n – next window
p – previous window
, – rename window
& – close window

Panes:
% – vertical split (left-right)
" – horizontal split (top-bottom)
o – switch between panes
q – show pane numbers
x – close pane
space – change pane layout
{ / } – move pane

Example: Running a Minecraft Server in Tmux

  1. Create a new session:

    tmux new -s minecraft-server

  2. Enter your server directory and start the server:

    cd minecraft-server

    java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

  3. Detach from the session:
    Ctrl + B, then D.

Your server will keep running in the background, even after you disconnect from SSH!

Summary

Tmux is a tool that makes server management much easier, especially if you run multiple tasks at once. If you have questions or want to learn more, feel free to leave a comment!

Sources:

Did you enjoy this article?

Subscribe to our newsletter to not miss the next ones!

Newsletter

Comments (0)

Loading...

Add Comment
Your comment will be published after approval by a moderator.
Loading...