The free Linux tool that keeps your terminal sessions alive forever

Even though most Linux distros don't require as much time in the terminal as they used to, eventually, it is going to come up.If you're doing anything remotely, executing a long task, or even just multitasking, the default tools may not be enough.That is where tmux comes in.

Terminal sessions weren't designed to last forever End the job when the window closes Most of the time when you're doing something in the terminal, that activity is tied directly to the terminal.For example, if I'm hosting a Minecraft server and I run the server executable, then that instance of the server on that specific terminal window.If I close it, the Minecraft server shuts down with it.

This applies to pretty much anything you do with the terminal—moving large files, SSH connections, searches, any executable that runs, system monitors, and more.Unless you specifically do something to make the job persist after the terminal is closed, they'll stop when the terminal closes.In some cases, that can be a good thing.

If a program freezes, you can just close the terminal to forcibly quit.You also don't want a demanding application quietly running in the background by accident without you realizing.Related How to Use the htop Command on Linux More than just a pretty face.

Posts 2 By  Dave McKay On the other hand, it is a problem if you something to keep going.It is particularly annoying when you're doing remote administration, and you want a job to keep running after you disconnect from the SSH session.Screen solved the problem a long time ago Screen is an application that was built decades ago to address the problem, and it generally works pretty well.

However, Screen is a product of its time.When you need something very lightweight and included by default, it is a good option.If you need something with more features, there is a more modern application: Tmux.

Tmux allows terminals to last as long as you need It does everything screen does and more Tmux is a terminal multiplexer that allows you to easily swap between applications in one terminal window, or detatch terminals virtually so they can keep running in the background and then reconnect later.If you're doing any kind of remote management, or you're using a PC that is command-line only—like a headless Ubuntu server that you have a monitor and keyboard attached to—then it is a fantastic option.No more closed servers Originally, I started using tmux because my Minecraft server would shut off anytime I ended the SSH connection.

That was a problem, since restarting my PC, a Windows update, or even accidentally closing the Terminal window kills the SSH connection.Now, I just create a new tmux session as soon as I connect to my Minecraft server.For example, I might run: tmux new -s mcserver Anything I run within that session will stay running even when I disconnect.

Whenever I want to come back to do something—like restart the server or access the admin panel—I just need one command.tmux attach-session -t mcserver You're not limited to hosting servers, either.Any time you think a process might take longer than a few minutes (like copying a large number of files) I'd recommend using a tmux session.

It ensures you won't accidentally interrupt some process in the middle.You have a long history of your actions Every terminal out there keeps a running log of the things you enter.That serves multiple purposes.

If a command you enter accidentally breaks something, you're not left wondering about the details—you can just check what you did.That makes troubleshooting easier.Alternatively, if there is an elaborate command you find yourself running a lot, you don't need to type the entire thing in over and over again.

You can just go back in your history then tap Enter to run the same command again.Subscribe to the newsletter for more tmux tips Level up your tmux skills - subscribe to the newsletter for practical guides, configuration examples, and broader Linux tools coverage that helps you manage long-running processes, headless systems, and self-hosted services with confidence.Get Updates By subscribing, you agree to receive newsletter and marketing emails, and accept our Terms of Use and Privacy Policy.

You can unsubscribe anytime.One of the advantages of tmux, which I've found to be especially helpful on my home server, is the extensive history.By default, it'll save several thousand commands.

You can also change that limit by editing the .tmux.conf file, which is located in your user directory.Tmux makes multitasking better Besides its ability to ensure that you don't lose a task in progress when you close a window or exit SSH, tmux is also handy for general multitasking.If you're using a Linux distro with a graphical user interface (GUI), multitasking isn't a problem—you can just open up another terminal if you need one.

However, if you're working on a system that doesn't have a GUI, you don't have that option.Tmux allows you to open any number of sessions so that you can easily switch between tasks whenever you want, even if a process running in one session will take three hours and the other will finish in 30 seconds.Tmux is an essential tool for anyone self-hosting Regardless of what fancy dashboards you set up, if you're self-hosting, you're eventually going to have to work using the command line.

Tmux is one of those tools you won't need to use all the time, but when it becomes necessary, you'll be very glad to have it.Dell XPS 13 Plus with Linux Operating System Ubuntu Linux 22.04 LTS CPU 13th Gen Intel Core i7-1360P $1399 at Dell Expand Collapse

Read More
Related Posts