Situatie
You want long-lived terminal sessions that survive SSH disconnects, reboots, and accidental closures — but tmux
or screen
feel too manual for novice users or scripts. You want this to just happen when you log in.
Solutie
Solution Overview:
Use a systemd user service to automatically spawn (or reattach) to a named tmux session every time you log in.
Steps:
-
Install tmux:
-
Enable systemd lingering for your user so services persist:
-
Create the service file:
Paste this:
-
Enable and start the service:
-
Optional: Add this to
.bashrc
or.zshrc
to auto-attach:
Benefits:
-
Session always persists, even if SSH drops.
-
Auto-restarts after reboot.
-
No need to teach someone how to use tmux — it “just works”.
Leave A Comment?