提供:すだちWiki
移動先: 案内検索

Systemdコマンド早見表(CentOS7)

CentOS 7ではsystemdが導入されているので、サービスの管理が従来と大きく変わっています。

サービスの起動、終了など

操作 コマンド
起動 systemctl start sshd
終了 systemctl stop sshd
強制終了 systemctl kill -s 9 sshd
再起動 systemctl restart sshd
設定反映 systemctl reload sshd
状態取得 systemctl status sshd
自動起動を有効 systemctl enable sshd
自動起動を無効 systemctl disable sshd
自動起動の状態確認 systemctl is-enabled sshd
サービス一覧の表示 systemctl --type service

ログのありか

Systemdには専用のjournalctlコマンドが用意されています。

特定のサービスのログを確認

[root@host3 ~]# journalctl -u sshd

終了は「q」キーを押す。

最新ログ10件表示

最新ログ10件が表示される。

[root@host3 ~]# journalctl -f -u sshd
-- Logs begin at 水 2015-04-01 22:19:32 JST. --
 4月 09 12:36:26 host3.sudachi.jp sshd[30777]: Connection closed by 127.0.0.1 [preauth]
 4月 09 12:41:26 host3.sudachi.jp sshd[30998]: Connection closed by 127.0.0.1 [preauth]
 4月 09 12:46:26 host3.sudachi.jp sshd[31064]: Connection closed by 127.0.0.1 [preauth]
 4月 09 12:51:26 host3.sudachi.jp sshd[31138]: Connection closed by 127.0.0.1 [preauth]
 4月 09 12:56:26 host3.sudachi.jp sshd[31246]: Connection closed by 127.0.0.1 [preauth]
 4月 09 13:01:26 host3.sudachi.jp sshd[31442]: Connection closed by 127.0.0.1 [preauth]
 4月 09 13:06:26 host3.sudachi.jp sshd[31506]: Connection closed by 127.0.0.1 [preauth]
 4月 09 13:10:55 host3.sudachi.jp sshd[31573]: Connection closed by 127.0.0.1 [preauth]
 4月 09 13:11:26 host3.sudachi.jp sshd[31634]: Connection closed by 127.0.0.1 [preauth]
 4月 09 13:16:26 host3.sudachi.jp sshd[31701]: Connection closed by 127.0.0.1 [preauth]

「Ctrl」キーを押しながら「c」キーを押す

その他管理機能

シングルユーザーモードに入る

[root@host3 ~]# systemctl rescue

マルチユーザーモードに戻る

[root@host3 ~]# systemctl default