SystemD
Booting, Shutting down and the like
Problems shutting down
In case there are problems:
SystemD and tty
Don't clear tty1 before login screen appears
Debian 8: "edit" command of systemctl is not available.
systemctl edit getty@tty1
[Service] TTYVTDisallocate=no
Set another number of ttys than 6
In /etc/systemd/logind.conf, locate NAutoVTs and change its value.
journald on tty
Let's have journald output on tty12 for example: Create file /etc/systemd/journald.conf.d/fw-tty12.conf (perform mkdir /etc/systemd/journald.conf.d/ if necessary) and put
[Journal] ForwardToConsole=yes TTYPath=/dev/tty12 MaxLevelConsole=info
inside this file, then do a
systemctl restart systemd-journald
Arbitrary program on specific tty
This SystemD service starts "htop" on tty11 (as user "nobody" for security reasons):
[Unit] Description=htop on tty11 [Service] Type=simple ExecStart=/usr/bin/sudo -u nobody /usr/bin/htop StandardInput=tty StandardOutput=tty TTYPath=/dev/tty11 [Install] WantedBy=multi-user.target
It can be saved in /etc/systemd/system
as htop.service
and later be started by systemctl start htop
. If it should be started at boot, systemctl enable htop
can be used.
Credits - I have enhanced it by "sudo -u nobody", otherwise anybody with physical access to the system would be able to manipulate it, i.e. killing processes by pressing F9.
Networking
Accounting
Requires at least version 235 (Debian 11 has 247, Ubuntu 20.04 LTS has 245).
In the service file, add this in section [[Service]]:
IPAccounting=yes
It can also be used for the time a program is running:
systemd-run -p IPAccounting=1 -t program
Tested on Ubuntu 20.04: Did not work!