Systemd is the newer linux init/system manager tool which is actually a replacement over tradition SysV init system. Systemd can be controlled by systemctl commandline tool. In this article, I would show some of the use/examples of systemctl command.

systemctl list-units

list-units

useful options/flags: [–all] [-state=inactive] [–type=service #target: to show available targets]

Viewing unit files: systemctl list-unit-files

root@gopal-virtual-machine:~# systemctl list-unit-files –state=enabled
UNIT FILE                                        STATE
acpid.path                                       enabled
cups.path                                        enabled
accounts-daemon.service            enabled

systemctl cat/show <servicename>.service #cat for showing actual configuration for the service, show for low level properties of unit. In case of show, we can add -p <property name> to show only that property and its config value

root@gopal-virtual-machine:~# systemctl cat rsync.service
# /lib/systemd/system/rsync.service
[Unit]
Description=fast remote file copy program daemon
ConditionPathExists=/etc/rsyncd.conf

[Service]
ExecStart=/usr/bin/rsync –daemon –no-detach

[Install]
WantedBy=multi-user.target
root@gopal-virtual-machine:~# systemctl show rsync.service
Type=simple
Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=1min 30s

systemctl edit [–full] httpd.service
systecmtl list-dependencies httpd.service #eg graphical.target

list-depedencies
 systemctl start/stop httpd.service
 systemctl enable/disable httpd.service
 systemctl mask/unmak httpd.service #Mask service wont be started unless unmasked
 systemctl is-active/is-enabled/is-failed httpd.service
 systemctl reload-or-restart sshd.service
 systemctl status httpd.service #Service status, CGroup hierarchy and initial few logs related to service

systemctl poweroff/reboot/halt/rescue
Advertisements