Sharing Terminal Screen Using Tmux

Sharing your terminal input and output can be done in different ways.

  1. kibitz, see Linux commands: expect and kibitz
  2. VNC
  3. Skype / Teams / Zoom, etc.
  4. tmux

1. tmux essentials. tmux (tmux wiki) uses the following vocabulary and hierarchy.

  1. server
  2. session-group
  3. session
  4. client
  5. window
  6. pane

The tmux-server listens on a socket. The tmux-client talks to this socket. A tmux-server may have 0, 1, …, n tmux-sessions. A tmux-client connects to a tmux-session. Two or more different tmux-clients may connect to the same tmux-session (that’s what this post will lead to). Each tmux-session has 1, …, n tmux-windows (so at least one). Each tmux-window has 1, …, n tmux-panes (so at least one). Sessions in the same group share the exact same set of windows, except the current window, i.e., closing or creating new windows in this group affect all sessions in this group.

Below .tmux.conf is my preferred configuration and is in no way required for sharing terminal screens. Your file .tmux.conf can be empty or absent at all.

# The default key is C-b because the prototype of tmux was originally
# developed inside screen and C-b was chosen not to clash with
# the screen meta key.
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# Set a  scrollback buffer limit
set -g history-limit 100000

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on

# Enable vi keys for working with buffers
setw -g mode-keys vi
# Constrain window only if another session is looking at it
setw -g aggressive-resize on
# Always resize windows to the larger/smallest session containing the window
#setw -g window-size largest
setw -g window-size smallest

new-session -s klm -n gen zsh
#new-window -t0 -n gen zsh
new-window -t1 -n bin zsh
new-window -t2 -n etc zsh
new-window -t3 -n man zsh
new-window -t4 -n root zsh
new-window -t5 -n log zsh
new-window -t6 -n ssh zsh
new-window -t7 -n music zsh
new-window -t8 -n chrome zsh
new-window -t9 -n Dwn zsh
split-window -h -t2
split-window -h -t8
select-window -t0

Starting tmux is now

tmux start-server \; attach-session

or in abbreviated form

tmux start \; a

Below screenshot shows all those 10 windows in action. One of those windows, here number 8, has two panes.

2. Screen sharing. If two different users A and B on a single Linux machine want to share their terminal screen, they have to do the following:

  1. User A: open a tmux using a “special” socket: tmux -S /tmp/userA_socket new-session -s userA_session
  2. User A: making socket accessible to user B: chmod 777 /tmp/userA_socket
  3. User B: access tmux from user A: tmux -S /tmp/userA_socket attach -t userA_session

So two users spawn two clients which connect to the same session managed by one server.

Instead of creating a new socket, /tmp/userA_socket, one can also use the default socket used by tmux, which is /tmp/tmux-/default. If chmod 777 is too risky, then use ACL:

setfacl -m u:UserB:rwx /tmp/userA_socket

You can achieve a similar effect with GNU screen, although one of the participants needs to setuid-root the screen program. If you do not have root access to the machine in question, then GNU screen is not an option.

J-Pilot Data on Android Phone: Contacts

Keeping J-Pilot data in sync with Android smartphone is quite a challenge. See my post about Google calendar. Copying contact data from J-Pilot to Android in the past went like this:

  1. Export data from J-Pilot in vCard (vcf) format
  2. If required, fiddle with this vcf file with some Perl script
  3. Stopping contact app in Android and stopping WiFi. Deleting all data in Android app.
  4. Manually delete contacts in Google Contacts in batches of ca. 500 records (Added 10-May-2020: Meanwhile there is no longer a limit here, so you can delete all your contacts in one go.)
  5. Import vCard data in Google Contacts
  6. Turn on WiFi on Android, starting contact-app

As one can easily see, this was very cumbersome. To make this even more difficult, now Google has limited the number of imported records in vCard file to 1,000 records per day. If you have more than that, then you are stuck. The limits are documented in quotas. Continue reading

Surfing the internet with 1 GBit/s

Adding 30 Cents to my monthly bills bought me Gigabit internet access. I now pay 39.99 EUR per month. Previously I had 100 MBit/s. From user’s experience I do not feel any significant difference. Of course, for all my mobile devices, like smartphones, laptop, there is and will be no difference as Wi-Fi does not really offer high transmission rates, unless you are very close to the emitting antennas.

Speed measured by

Continue reading