Table of Contents

, , , , , , , , , ,

tmate

Tmux

As a Linux Administrator, I find myself opening several SSH connections to my servers on a daily basis. Often times it will be multiple connections to the same server. This can be very cumbersome and adds a lot of clutter to your desktop as you work. Of course, you can open a new tab in your GUI terminal tool (gterm, xterm, putty, etc), but that only works if you’re using a GUI tool and the machine(s) you are connecting to don’t limit you to a single login.

There are solutions to this dilemma. I choose to use tmux. If you are familiar with the screen tool, tmux is very similar. These tools allow you to have a single connection or window to you shell account. They allow you to leave a program or script running and “detach” so you and leave and it will keep running. You can reattach later and continue where you left off . This is like watching a TV show and turning off the TV. Then turning it back on to see the same channel.

Getting started

To install tmux, use your package manager.

In CentOS/RedHat:

$ sudo yum install tmux

In Debian/Ubuntu:

$ sudo apt-get install tmux

To start a tmux session:

$ tmux

To attach to an existing session:

$ tmux a

Detaching from your current session (default):

$ CTRL + b + d

Features

In addition, you can share your screen with another user. For example, you are working on a project but are facing an issue. The only other person that has an account or the knowledge of your project is located somewhere else and cannot look over your shoulder. Of course, you can send the file(s) and describe the issue you’re having. However, many times it’s helpful to see the effects of the changes as they’re tested. So you could have another user login to the same system and attach to the same tmux session.

The tmux utility is configurable so you can choose the key bindings (key combinations for tasks) and other commands for tmux settings you want to use. Because this is a simple text file, you can copy it to other machines and user accounts to have the same settings. A huge benefit of tmux is that it allows for custom screen splitting. This is very useful for editing and testing script while viewing logs at the same time.

Notice the number of connections in the bottom right pane. There is only 1 shell process. As I said earlier, if the machine only allows 1 connection per user, then you would not be able to have multiple connections or terminals. This would provide the ability to work with multiple shells for productivity.

Conclusion

This utility is very nice for keeping your connections organized and promotes better productivity than having multiple windows open with different shells. The team collaboration and ability to detail/reattach are the primary reasons I use this utility.