0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

systemclt & service 早見表 (CentOS7 & Amazon Linux 2)

Last updated at Posted at 2020-09-08

CentOS7 や Amazon Linux 2 での systemctl や service の早見表。

root や sudo で実行する必要あり。
基本的に sudo を基本に書いていきます。

systemclt と service は基本的に反対

起動

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

$ sudo systemctl start nginx
$ sudo service nginx start 

設定反映 (config 読み込み)

設定の適用なので、サービスの瞬断は無いはず。

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

$ sudo systemctl reload nginx
$ sudo service nginx reload

再起動

サービスの瞬断あり。

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

$ sudo systemctl reload nginx
$ sudo service nginx reload

停止

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

$ sudo systemctl stop nginx
$ sudo service nginx stop 

ステータス表示

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

$ sudo systemctl status nginx
$ sudo service nginx status 

サービス自動起動設定

サーバー起動時に、自動的にサービスを立ち上げるかどうかの設定。

有効化

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

$ sudo systemctl enable nginx
$ sudo service nginx enable

サービス自動起動設定

無効化

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

$ sudo systemctl enable nginx
$ sudo service nginx enable

サービス一覧表示

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

設定ファイルの再読み込み

$ sudo systemctl daemon-reload
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?