systemclt & service quick reference table (CentOS7 & Amazon Linux 2)

A quick reference table of systemctl and service on CentOS7 and Amazon Linux 2.

Must be run as root or sudo. Basically, I will write based on sudo.

systemctl and service are basically opposite

Start-up

$ sudo systemctl start [UNIT]
$ sudo service [UNIT] start 

Example

$ sudo systemctl start nginx
$ sudo service nginx start 

Reflect settings (read config)

Since the settings are applied, there should be no interruption of service.

$ sudo systemctl reload [UNIT]
$ sudo service [UNIT] reload

Example

$ sudo systemctl reload nginx
$ sudo service nginx reload

Reboot

There is a momentary interruption of service.

$ sudo systemctl restart [UNIT]
$ sudo service [UNIT] restart

Example

$ sudo systemctl reload nginx
$ sudo service nginx reload

Stop

$ sudo systemctl stop [UNIT]
$ sudo service [UNIT] stop

Example

$ sudo systemctl stop nginx
$ sudo service nginx stop 

Status display

$ sudo systemctl stop [UNIT]
$ sudo service [UNIT] stop

Example

$ sudo systemctl status nginx
$ sudo service nginx status 

Service automatic start setting

Setting whether to start the service automatically when the server starts.

activation

$ sudo systemctl enable [UNIT]
$ sudo service [UNIT] enable

Example

$ sudo systemctl enable nginx
$ sudo service nginx enable

Service automatic start setting

Invalidation

$ sudo systemctl enable [UNIT]
$ sudo service [UNIT] enable

Example

$ sudo systemctl enable nginx
$ sudo service nginx enable

Service list display

$ sudo systemctl list-unit-files --type=service

Reload configuration file

$ sudo systemctl daemon-reload


Recommended Posts

systemclt & service quick reference table (CentOS7 & Amazon Linux 2)
Column type quick reference table
[Rails] haml code quick reference table