Explain how to manage SYSTEMD services in Linux systems

Source: Internet
Author: User

(1) What is a unit

Prior to RHEL7, service management was distributed by SYSV Init or upstart under/ETC/RC.D/INIT.D script management. These scripts are classic bash scripts that allow administrators to control the state of a service. In RHEL7, these scripts are replaced by service unit files.

In Systemd, services, mounts, and so on are called units, so there are many cell types in systemd, and the extension of service unit files is. Service, similar to the functionality of the script. For example, there are parameters for viewing, starting, stopping, restarting, enabling, or prohibiting services.

Systemd Cell file Placement:

/USR/LIB/SYSTEMD/SYSTEM/SYSTEMD default unit File installation directory

The/RUN/SYSTEMD/SYSTEMSYSTEMDSYSTEMD unit is created at runtime, which takes precedence over the directory

/etc/systemd/system system administrators Create and manage cell directories with the highest priority.

(2) SYSTEMD service Management

Use the SYSTEMCL command to control Services, service commands, and Chkconfig commands are still available, but are primarily for compatibility reasons and should be avoided as much as possible.

When using the Systemctl command, the extension of the service name can be fully written, for example:

The code is as follows:

Systemctl Stop Bluuetooth.service

You can also ignore, for example:

The code is as follows:

Systemctl Stop Bluetooth

Systemctl Common commands:

Start a service

The code is as follows:

Systemctl Start Name.service

Turn off services

The code is as follows:

Systemctl Stop Name.service

Restart Service

The code is as follows:

Systemctl Restar Tname.service

Restart the service only when the service is running

The code is as follows:

Systemctl Try-restart Name.service

Reload the service configuration file

The code is as follows:

Systemctl relaod Name.service

Check Service operation status

The code is as follows:

Systemctl Status Name.service

Or

The code is as follows:

Systemctl is-active Name.service

Show all service status details

Copy Code

The code is as follows:

Systemctl List-units--type Service--all

Allow Service to boot

The code is as follows:

Systemctl Enable Name.service

Disable service boot up

The code is as follows:

SYSTEMCLT Disable Name.service

Check the service boot state

The code is as follows:

Systemctl Status Name.service

Or

The code is as follows:

Systemctl

Is-enabled Name.service

List all services and check if boot up

The code is as follows:

Systemctl list-unit-files--type Service

(3) Service Details view

Use the following command to list the services:

The code is as follows:

Systemctl list-units--type Service

Only the service that is active is listed by default, and if you want to see all the services, use the--all or-a parameter:

The code is as follows:

Systemctl List-units--type Service--all

Sometimes you want to see so you can set up a boot-up service, using the following command:

The code is as follows:

Systemctl list-unit-files--type Service

To view service details, use the following command:

The code is as follows:

Systemctl Status Name.service

Service Information keyword explanation

The loaded service has been loaded to display the absolute path of the cell file, and the label cell file is available.

The active service has been run and has startup time information.

Main PID is the same as process name PID, main process PID.

Attachment information for the status service.

Attachment information for process-related processes.

Cgroup information for the cgroup process.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.