Thanks topic. I solved for Ubuntu 24. This is my step-by-step explanation.
- Preparation
Preparation
sudo apt install htop nano tmux -y Make service to call tmux and start the application (in this example htop but it can be any user application).
sudo nano /etc/systemd/system/myservice.service[Unit] Description=my tmux service After=multi-user.target # https://unix.stackexchange.com/questions/404667/systemd-service-what-is-multi-user-target [Service] User=q Group=q ExecStart=bash -c "tmux new-session -s q -d 'htop'" Type=forking [Install] WantedBy=multi-user.targetAsk systemd to start our service at boot.
sudo systemctl enable myservice.serviceService will start after reboot. We should do reboot or start immediately.
sudo systemctl start myserviceYou can connect long way
ssh [email protected] tmux attachOr you can connect short way. Thanks topic
ssh [email protected] -t tmux a
sudo apt install htop nano tmux -y
- Make service to call tmux and start the application (in this example htop but it can be any user application).
sudo nano /etc/systemd/system/myservice.service
[Unit]
Description=my tmux service
After=multi-user.target # https://unix.stackexchange.com/questions/404667/systemd-service-what-is-multi-user-target
[Service]
User=q
Group=q
ExecStart=bash -c "tmux new-session -s q -d 'htop'"
Type=forking
[Install]
WantedBy=multi-user.target
- Ask systemd to start our service at boot.
sudo systemctl enable myservice.service
- Service will start after reboot. We should do reboot or start immediately.
sudo systemctl start myservice
- You can connect long way
ssh [email protected]
tmux attach
Or you can connect short way. Thanks topic
ssh [email protected] -t tmux a