How to Share Your Tmux Session in Real-time with Wemux

A picture of a programmer working on a computer.

Wemux is a powerful tool that expands Tmux to allow for real-time multi-user sessions. It provides view-only as well as shared and individually controlled terminals, giving you the freedom to run Tmux across multiple users. In this article, I will go through the process of installing Wemux, creating a guest user, and share Tmux on a real-time server.

Installing Wemux in Linux

The first step in installing Wemux is to make sure that your system is up-to-date:

sudo apt update && sudo apt upgrade -y

Install the dependencies for Wemux using your package manager:

sudo apt install git tmux ssh

Navigate to your home directory, then clone the Wemux repository from the project’s Github page:

cd ~/
git clone https://github.com/zolrath/wemux.git

Copy the git directory to a shared system folder. In my case, I will copy it to my “/usr/local/share” directory:

sudo cp -rv ~/wemux /usr/local/share

Go to the system directory where you copied Wemux, then create a symbolic link to a folder that’s a part of your $PATH variable:

cd /usr/local/share
sudo ln -s /usr/local/share/wemux/wemux /usr/local/bin/wemux
A screenshot showing the creation of a symbolic link for Wemux.

Copy the prebuilt config file from the Wemux system directory to “/usr/local/etc.” This contains all the necessary settings and permissions to create a Wemux session:

sudo cp /usr/local/share/wemux/wemux.conf.example /usr/local/etc/wemux.conf

Reload your current shell session, then run the following command to confirm that you’ve installed Wemux properly:

wemux help
A screenshot showing the default help screen for Wemux.

Good to know: looking to expand your familiarity with the command line? Check out our guide to getting started with the Linux terminal.

Setting Up Your First Wemux Session

At this point, you now have Wemux running on your machine. However, you still won’t be able to create a shareable terminal session. This is because Wemux will only listen to commands coming from a valid “Wemux user.”

To create your first Wemux session, open the config file that you’ve copied “/usr/local/etc:”

sudo nano /usr/local/etc/wemux.conf

Scroll to the HOST OPTIONS section, then paste the following line of code underneath it:

host_list=(YOUR_USERNAME)

Replace the “YOUR_USERNAME” with your system’s username. You can find this by running whoami on a terminal window.

A terminal highlighting the host_list variable on the Wemux config file.

Scroll down to the MULTI-HOST OPTIONS section, then remove the pound (#) sign before the allow_server_change variable. This will allow you to run and share multiple real-time Tmux sessions on the same Wemux machine.

A screenshot highlighting the allow_server_change variable on the Wemux config file.

Save your modified config file, then run the following command to test whether Wemux can create a new session properly:

wemux start
A screenshot showing Wemux working properly on Ubuntu Linux.

Joining in a Shared Wemux Session

With Wemux working properly, joining a shared session is as simple as connecting to the machine through SSH. Start by making sure that the guest user has a proper shell account on your system:

sudo adduser alice

Type a password for your new shell user, then provide any identifying details for the user account.

A terminal showing the process of creating a new guest user for Wemux.

Make sure that you’ve created your new user properly by checking if it has a home directory:

ls -l /home

Open your shared terminal for guests by running the following command inside your host’s Wemux session. This a Tmux-specific flag that allows other users in the system to connect and interact with your shared terminal server:

tmux server-access -a GUEST_USERNAME_HERE
A terminal showing the Tmux command to allow for guest access on Wemux.

Note: this is a non-persistent command. This means that you need to run it whenever you share a real-time Tmux session in Wemux.

Login as your guest user, then run the following command to connect to the host’s Wemux session:

wemux m
A terminal showing the guest user connecting to the remote Wemux machine.

On a side note: optimize your terminal setup today by looking at the best productivity-focused plugins for Tmux.

Allowing Terminal Collaboration in Wemux

Aside from showing a read-only mode of the terminal, Wemux hosts can also allow guests to interact with a shared session. To do this, start by pressing Ctrl + B, then D to detach from the current Wemux instance.

A terminal showing the output of a detached Tmux session.

Run the following command to stop the Wemux daemon:

wemux stop

Open the Wemux config file using your favorite text editor:

sudo nano /usr/local/etc/wemux.conf

Scroll to the host_list variable and then add the username of the user that you want to give editing access to.

A terminal showing the host_list variable showing two users.

It’s also possible to give specific system groups the privilege to run and interact with a shared Wemux session. To do this, uncomment the host_groups variable, then add the name of the group that you want to give editing privileges to.

A terminal showing the group-specific permissions for editing privileges in Wemux.

Save your config file, then start a new Wemux session to apply your new settings.

Confirm that it’s working properly by logging in as your guest user, then running wemux attach to connect to the current server.

A terminal showing the guest user having editing privileges on the shared Tmux session.

Managing Multiple Wemux Servers

Another useful feature of Wemux is its ability to run multiple independent terminal servers. This is especially helpful if you want to create terminal groups for different tasks.

Begin by pressing Ctrl + B, then D to detach your host user to the current Wemux session.

Run the following command to create a separate Wemux terminal server, then immediately start it:

wemux join YOUR_GROUP_NAME
wemux start

Go to your guest user, then run wemux join followed by the name of your new server. In my case, I named my group “my-new-project.”

A terminal showing the command to create a new shared server session.

Run wemux attach to connect the guest account to your new server.

A terminal showing the guest user joining the new shared terminal session.

Learning how to create a shareable Tmux session with Wemux is just one of the things that you can do with this wonderful terminal multiplexer. Looking to optimize your terminal experience? Check out some of the tricks that I did to streamline Tmux today.

Image credit: Grok via x.ai. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red Avatar