Debian: Systemd command line examples

Hi,

simply a collection of systemd command line examples. To be continued……

Set hostname + fqdn

hostnamectl

Example
sudo hostnamectl set-hostname yourHost.yourDomain.net

resolv.conf

/etc/systemd/resolved.conf


Bootlog

journalctl -b

Default target (in former releases the equivalent to System V Runlevel)

systemctl get-default
systemctl set-default -f multi-user.target

list targets

systemctl list-units --type=target

list all enabled services

systemctl list-unit-files|grep enabled


journalctl -f

Log for specfic service or unit

journalctl -u bind9

Show unit environents

systemctl show named

Analyze Startup order and times

systemd-analyze
systemd-analyze critical-chain

List all services want by a target in filesystem

ls -l /etc/systemd/system/multi-user.target.wants

Set environment varibales for a service, create a directory .d

mkdir /etc/systemd/system/docker.service.d

Create a file /etc/systemd/system/.d/http-proxy.conf
And add

[Service]
Environment="HTTP_PROXY=http://192.168.56.1:5865/
Environment="HTTPS_PROXY=http://192.168.56.1:5865/

Show configured environment

systemctl show docker --property Environment

Reload daemons

systemctl daemon-reload

Restart a daemon

systemctl restart docker

Default target: Boot to text console

systemctl set-default multi-user.target

Default target: Boot to graphical desktop

systemctl set-default graphical.target

Switch from text console to graphical UI

systemctl isolate graphical.target

Switch to text console

systemctl isolate multi-user.target

Switch to rescue console

systemctl rescue

and to emergency console

systemctl emergency

List all targets

systemctl list-units --type target --all

Leave a Reply Cancel reply