Introduction and use of systemd for CentOS7 startup management

Source: Internet
Author: User

Introduction and use of systemd for CentOS7 startup management

Systemd provides a better framework to indicate the dependency between system services.
Implements parallel startup of services during system initialization and reduces the overhead of Shell Systems.
The objective of systemd is to start fewer processes as much as possible and start more processes in parallel as much as possible.
Systemd minimizes the dependency on shell scripts.

Systemd unit type

(Systemctl -- type = unit type, used to filter units ):
Service: Manages background services;
Automatic mount: used to mount the file system;
Target: running level;
Socket: used to create a socket. After accessing the socket, you can use the dependency to indirectly start another unit;

Boot Service Management

========================================================== ==========
Systemd adds a new unit (daemon)
That is, it uses systemd for management, and/sbin/chkconfig -- add foo is equivalent
Put the newly generated foo. service under/usr/lib/systemd/system/, and then use the load command to import
Systemctl load foo. service

Delete unit (daemon)
There is no command for deleting a unit. The usual practice is to stop daemon and delete the corresponding configuration file.

Start unit
Systemctl enable postfix. service
Add soft links from/usr/lib/systemd/system/to/etc/systemd/system/multi-user.target.wants/
Ln-s '/usr/lib/systemd/system/postfix. service'/etc/systemd/system/multi-user.target.wants/postfix. Service'

Start unit
Systemctl disable httpd. service
Delete soft links under/etc/systemd/system/multi-user.target.wants

Check whether startup is enabled
Systemctl is-enabled. service # query whether the service is started

Systemd to view the auto-Start Program
Equivalent to chkconfig -- list
Ls/etc/systemd/system/multi-user.target.wants/

View the loading and activity of the systemd Unit
Systemctl

Display failed start units
Systemctl -- failed

View All units managed by systemd
Systemctl list-unit-files

Service Management

========================================================== ==========
Start the service
Systemctl start httpd. service
Close service
Systemctl stop httpd. service
Restart service
Systemctl restart httpd. service
Reload
Systemctl reload httpd. service
View status
Systemctl status httpd. service
Including the startup status, start time, main process and related processes, and related logs

Running level

========================================================== ==========
Systemd replaces runlevel with target. Multiple 'targets' can be activated simultaneously.
Systemd does not use the/etc/inittab. How can I view the default running level of the system?
Ll/etc/systemd/system/default.tar get
View the file to which this soft link actually points

How to view the current running level of the system
Runlevel is still available
The systemd method is systemctl list-units -- type = target.

The current target is changed, and the restart is invalid.
Systemctl isolate graphical.tar get

Modify default running level
1. delete an existing Symbolic Link
Rm/etc/systemd/system/default.tar get
2. The default level is 3 (text mode)
Systemctl enable multi-user.target
Equivalent to ln-s/lib/systemd/system/multi-user.target/etc/systemd/system/default.tar get
3. Restart
Reboot

The running level is as follows:
Runlevel0.target-> poweroff.tar get
Runlevel1.target-> rescue.tar get
Runlevel2.target> multi-user.target
Runlevel3.target> multi-user.target
Runlevel4.target> multi-user.target
Runlevel5.target-> graphical.tar get
Runlevel6.target-> reboot.tar get

CentOS7/RHEL7 systemd

Why is systemd so quickly adopted?

Systemd and sysVinit Color comparison table

So useful! Run the systemd command to manage the Linux system!

Analysis of Linux init system initialization, Part 1: Systemd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.