This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
linux:centos7_services [2019/06/18 13:21] admin created |
linux:centos7_services [2019/06/18 13:51] (current) admin |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| Previous versions of CentOS/RedHat Linux use init scripts located in the /etc/rc.d/init directory to start and stop services. In CentOS/RHEL 7, these init scripts have been replaced with systemd service units. Service units have a .service extension. Use the systemctl command as follows to list all loaded service units: | Previous versions of CentOS/RedHat Linux use init scripts located in the /etc/rc.d/init directory to start and stop services. In CentOS/RHEL 7, these init scripts have been replaced with systemd service units. Service units have a .service extension. Use the systemctl command as follows to list all loaded service units: | ||
| + | <code bash> | ||
| # systemctl list-units --type service --all | # systemctl list-units --type service --all | ||
| UNIT LOAD ACTIVE SUB DESCRIPTION | UNIT LOAD ACTIVE SUB DESCRIPTION | ||
| Line 10: | Line 11: | ||
| abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT | abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT | ||
| abrt-xorg.service loaded inactive dead ABRT Xorg log watcher | abrt-xorg.service loaded inactive dead ABRT Xorg log watcher | ||
| - | abrtd.service loaded inactive dead ABRT Automated Bug Reporting Tool | + | abrtd.service loaded inactive dead ABRT Automated Bug |
| - | Check status of service with systemd | + | </code> |
| - | 1. systemd service units correspond to system services. Use the following command to display detailed information about a service unit. This example displays information about the ntpd.service service unit. You can omit the .service extension if you want. | + | |
| + | ===== Check status of service with systemd ===== | ||
| + | |||
| + | - systemd service units correspond to system services.Use the following command to display detailed information about a service unit. This example displays information about the ntpd.service service unit. You can omit the .service extension if you want. | ||
| + | |||
| + | <code bash> | ||
| # systemctl status ntpd.service | # systemctl status ntpd.service | ||
| ● ntpd.service - Network Time Service | ● ntpd.service - Network Time Service | ||
| Line 23: | Line 28: | ||
| Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. | Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. | ||
| - | The following information is available for the specified service unit: | + | </code> |
| + | The following information is available for the specified service unit: | ||
| - | Loaded: If the service is loaded, the absolute path to the service unit file, and if the service unit is enabled | + | * Loaded: If the service is loaded, the absolute path to the service unit file, and if the service unit is enabled |
| - | Active: If the service unit is running and a timestamp | + | * Active: If the service unit is running and a timestamp |
| - | Main PID: The Process ID of the corresponding system service and the service name | + | * Main PID: The Process ID of the corresponding system service and the service name |
| - | Status: Additional information about the corresponding system service | + | * Status: Additional information about the corresponding system service |
| - | Process: Additional information about related processes | + | * Process: Additional information about related processes |
| - | CGroup: Additional information about related Control Groups | + | * CGroup: Additional information about related Control Groups |
| - | The most recent log entries are displayed if the command is executed by the root user. | + | |
| + | The most recent log entries are displayed if the command is executed by the root user. | ||
| You would see the status of the service in green (if running) or in red (if stopped) as shown below. | You would see the status of the service in green (if running) or in red (if stopped) as shown below. | ||
| - | service status check in RHEL CentOS 7 | + | {{ :linux:service-status-check-in-rhel-centos-7.png |}} |
| - | 2. To list the status of all services: | ||
| + | - To list the status of all services: | ||
| + | |||
| + | <code bash> | ||
| # systemctl list-unit-files --type=service --all | # systemctl list-unit-files --type=service --all | ||
| + | </code> | ||
| + | |||
| For Example : | For Example : | ||
| + | <code bash> | ||
| # systemctl list-unit-files --type=service | # systemctl list-unit-files --type=service | ||
| UNIT FILE STATE | UNIT FILE STATE | ||
| Line 51: | Line 62: | ||
| abrt-vmcore.service enabled | abrt-vmcore.service enabled | ||
| abrt-xorg.service enabled | abrt-xorg.service enabled | ||
| + | </code> | ||
| You should see the service in disabled mode highlighted with red color and the service in enabled mode highlighted with green color as show below. | You should see the service in disabled mode highlighted with red color and the service in enabled mode highlighted with green color as show below. | ||
| - | centOS RHEL 7 find service status | + | {{ :linux:centos-rhel-7-find-service-status.png |}} |
| + | |||
| + | ===== Other commands to check the status of service ===== | ||
| - | Other commands to check the status of service | ||
| Use the following command to check whether a service is running (active) or not running (inactive): | Use the following command to check whether a service is running (active) or not running (inactive): | ||
| + | <code bash> | ||
| # systemctl is-active sshd | # systemctl is-active sshd | ||
| active | active | ||
| + | </code> | ||
| Use the following command to check whether a service is enabled or disabled: | Use the following command to check whether a service is enabled or disabled: | ||
| + | <code bash> | ||
| # systemctl is-enabled sshd | # systemctl is-enabled sshd | ||
| enabled | enabled | ||
| + | </code> | ||
| + | <code bash> | ||
| # systemctl is-enabled httpd | # systemctl is-enabled httpd | ||
| disabled | disabled | ||
| + | </code> | ||