This article is also posted on my blog, feel free to check the latest revision: About the Systemd
It has been a long time that the linux use init
to manage the startup process, such as sudo /etc/init.d/apache2 start
or service apache2 start
, but the init
is serial. To address this issue, the systemd
was born. The d is the abbreviation of daemon
, which means the systemd
is a daemon manager. The systemd substitutes the initd and becomes the default main process PID 1
.
You can check the version systemctl --version
.
sudo systemctl reboot
sudo systemctl poweroff
sudo systemctl suspend
Look up the host info, Architecture, Hardware, Kernel, Operating System, etc.
You can also query via
uname -a
.
Query the timezone.
Manage the login session.
There are 12 types of units:
You can also query them:
The unit config file is located at /etc/systemd/system/
. But most of them are the symbolic links to the real config file in /usr/lib/systemd/system/
.
The
systemctl enable
command will create a symbolic link to the real config file in/etc/systemd/system/
(if you config start on boot in the unit file, it will start on boot) And thesystemctl disable
command will remove the symbolic link. Such as
sudo systemctl enable clamd@scan.service
# which is equivalent to
$ sudo ln -s '/usr/lib/systemd/system/clamd@scan.service' '/etc/systemd/system/multi-user.target.wants/clamd@scan.service'
You can list all the config files:
systemctl list-unit-files
# the tail is the kind of unit, such as service(default), socket, etc.
There are four status of the unit:
enabled
: the unit is enableddisabled
: the unit is disabledstatic
: the unit is static, which only served as other unit's dependencymasked
: the unit is banned to be enabledsystemctl cat atd.service
can show the specific unit file.
The detail you can refer to the official document.
Once you adjust the unit file, you need to reload the systemd and restart the service:
sudo systemctl daemon-reload
sudo systemctl restart httpd.service
The target is a group of units, once the target is enabled, the units in the target will be enabled.
You can check the kernel log and the service log by only journalctl
. The config file is /etc/systemd/journald.conf
.
Reference
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。