I’ve yet to write my “Wonders of Tmux” entry but always have small tidbits to give in the meantime.

Sometimes sharing your whole desktop via Skype, Teamviewer, or some other screen-sharing system is overkill, at the very least harder to read and control remotely. Sharing a terminal session between two (or more) users is great for pair programming (especially if both users are vi or emacs users) or for one user to educate, walk-through, or troubleshoot something with another remote user – also great for showing how Tmux works! One can even split the screen in half and be SSH’d into multiple machines together!

There’s three ways that users can share a terminal session together. The first way requires a little more work from the person sharing their tmux session, the second and third require either sudo rights or being able to su to the other user’s account.

Similar to SSH, when you create a tmux session, it creates a temporary socket in the /tmp directory with the tmux user owning the file. This makes it unaccessible by other users.

Allow another user access to your tmux session:

# specify the name of your tmux socket with -S when creating it
tmux -S /tmp/pair
# chmod to allow other users to access it
chmod 777 /tmp/pair
 
# now the other user can connect with
tmux -S /tmp/pair attach

Sudo your way into another users tmux session

# Have the user create a tmux session
# ls -al /tmp to see which tmux session is owned by the user you want to share sessions with then
# in the following example tmux-502 is the tmux socket folder of the example user 
sudo tmux -S tmux-502/delfault attach

su your way into the session

su username # need user's password or sudo
tmux attach