Tmux is by far one of the most useful tools in the linux arsenal especially for long running jobs. Tmux is a linux terminal multiplexer, it allows terminal sessions to remain active long after the user has logged off their workstation.

In this tutorial I'll be using a CentOS 8 virtual machine.

Installing tmux:

First you will need to install the package for tmux.

yum install tmux -y

Create a new session:

Create a new tmux session. I will name my session NEW_SESSSION.

tmux new -s NEW_SESSION

Attach to new session:

The next step is to attach to the newly created session.

tmux attach -t NEW_SESSION

Detach from tmux session:

On your keyboard, press the following keys at the same time:

ctrl + b + d

This will keep the session running in the background, but will not terminate it.

Check running session:

To check what running sessions are available to connect to. You can use the following command to list all of the active sessions.

tmux ls

Terminating a session:

When you no longer need the tmux session you can terminate it by using the kill-session command.

tmux kill-session -t NEW_SESSION

Tmux has been super valuable in my professional life! Instead of designing a script to run in the background or using nohup, tmux allows to run the process in foreground in a persistent terminal session. Ideal for running a Minecraft server because it has a tendency to cause issues if ran in the background.