Making Changes to Daemon Files

Whenever a daemon file is changed in /etc/systemd/system/, the daemon files must be reloaded with:

systemctl daemon-reload

Starting Programs on Virtual Terminals

Most *nix derivates start a login program such as getty on multiple virtual terminals for the user to log-in when the system boots. On pre-systemd systems, /etc/inittab was used to spawn (and re-spawn) getty on the virtual terminals, which could also be used to run console programs such as htop instead of the login terminal.

The procedure with systemd is a little different and involves shutting down the tty services and creating a service file. The first thing to do is run:

systemctl

and search (using forward-slash / and typing in text to search) for getty. On a Debian system, one would find:

  getty@tty1.service                                                          loaded active running   Getty on tty2       
  getty@tty2.service                                                          loaded active running   Getty on tty2            
  getty@tty6.service                                                          loaded active running   Getty on tty6       

which means that getty will be spawned on tty1, tty2 and tty6. Whilst tty6 has a special meaning and is a fallback console to always provide the means for an operator to log-in, tty1 and tty2 could be used to spawn a different program such as htop.

In order for getty and htop to not race each other, the first step is to stop and disable the getty@tty1.service service:

systemctl stop getty@tty1.service
systemctl disable getty@tty1.service

Next, add the following contents to a file placed at /etc/systemd/system/htop.service:

[Unit]
Description=htop on tty1

[Service]
Type=simple
ExecStart=/usr/bin/htop
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty1
Restart=always
RestartSec=2

[Install]
WantedBy=getty.target

where:

  • /dev/tty1 is the virtual terminal to start htop on.

You can now enable and start the service via:

systemctl enable htop.service
systemctl start htop.service

and htop should appear on the first virtual terminal.


fuss/systemd.txt ยท Last modified: 2017/09/12 17:32 by office

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.