TrumanWong

service

Utilities for controlling system services

Supplementary instructions

service command is a utility tool used to control system services in Redhat Linux-compatible distributions. It can start, stop, restart, and shut down system services. It can also display the current status of all system services.

grammar

service(option)(parameter)

Options

-h: Display help information;
--status-all: Display the status of the service.

Parameters

  • Service name: The name of the service to be automatically controlled, that is, the name of the script file in the /etc/init.d directory;
  • Control commands: Control commands supported by system service scripts.

Example

When the host name, IP address and other information are modified, the network often needs to be restarted for it to take effect.

service network status
Configure the device:
lo eth0
Current active devices:
lo eth0

service network restart
Shutting down interface eth0: [OK]
Close loopback interface: [OK]
Set network parameters: [OK]
Pop up the loopback interface: [OK]
Pop-up interface eth0: [OK]

Restart mysql

service mysqld status
mysqld (pid 1638) is running...

service mysqld restart
Stop MySQL: [OK]
Start MySQL: [OK]