This tutorial will enable the Pi to start tmux after boot. If you have a LCD hooked up, you will see the tmux session and can control it from SSH.
This is very useful if you do not want to plug in keyboard to your Pi or other Debian computer but has a monitor for visual.

We need to create a bash sript, name it whatever you want but remember the file location:


$ nano /home/user/tmux.sh:

#!/bin/bash
sudo su username -c "/usr/bin/tmux kill-session -t ttty 2> /dev/null"
sudo su username -c "/usr/bin/tmux new-session -s ttty"

Make the script executable:

chmod +x /home/user/tmux.sh

Edit the getty servicefile:


$ sudo nano /etc/systemd/system/getty@tty1.service.d/override.conf
[Service]
ExecStart=
ExecStart=-/home/user/tmux.sh
StandardInput=tty
StandardOutput=tty

CAUTION: This may terminate your access over SSH and any program running on tty1.


sudo systemctl daemon-reload
sudo systemctl restart getty@tty1.service

Please refer to the original tutorial: unixtutorial.org
for more info.