Pair programming using tmux

Table of Contents

1. Introduction

I have recently discovered the joy of pair programming, its great for teaching about command line tools and programming, or even just working on a project. It basically allows people to use the same computer and the text editor at once.

I use tmux for this (Even though I don't really use it when not on a server). But most of the tutorials on the internet won't work without properly setting it up. I will go through a proper setup in this article on a Debian computer.

2. Creating a user for the Tmuxxers

When the users connect with each other they will need to use a separate user to run their commands, lets call this user tmuxshare. We will not allow password login for this,

tusharhero@pubnix:~$ sudo adduser --disabled-password tmuxshare
Adding user `tmuxshare' ...
Adding new group `tmuxshare' (1002) ...
Adding new user `tmuxshare' (1002) with group `tmuxshare (1002)' ...
Creating home directory `/home/tmuxshare' ...
Copying files from `/etc/skel' ...
Changing the user information for tmuxshare
Enter the new value, or press ENTER for the default
        Full Name []: 
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] Y
Adding new user `tmuxshare' to supplemental / extra groups `users' ...
Adding user `tmuxshare' to group `users' ...

3. Creating a group for the Tmuxxers

We don't want to give everyone access to the tmux shared sessions. So we will create a group for them, we will call it tmuxxers.

tusharhero@pubnix:~$ sudo groupadd tmuxxers

Then, add the users who you want to access the shared sessions.

tusharhero@pubnix:~$ sudo usermod -aG tmuxxers tusharhero

4. Allow tmuxxers to access the tmuxshare account

We will have to use sudo to give users in tmuxxers group the ability to log into tmuxshare. create a file called /etc/sudoers.d/tmux with this content.

%tmuxxers ALL=(tmuxshare) NOPASSWD: ALL

Use sudo -u tmuxshare -i to login into it.

5. Use tmux

You can now create and use tmux as usual.

5.1. creating a session

tmux new -s "session name"

5.2. connecting to a session

tmux attach -t "session name"

Date: 2023-10-23 Mon 14:22

Author: tusharhero

Email: tusharhero@sdf.org

Created: 2023-10-23 Mon 17:36

Validate