Linux での 5 つの基本的な chkconfig コマンドの例
これは継続中の Linux コマンド シリーズであり、chkconfig コマンドを使用可能なパラメータで効率的に使用する方法を確認します。 Chkconfig コマンド ツールを使用すると、コマンド ラインを通じて /etc/rd.d/init.d スクリプトでサービスの自動開始と停止を構成できます。いくつかの例を見てみましょう。
1. すべてのサービスをリストする
「–list」パラメータを使用すると、各実行レベル構成のすべてのサービスとその現在の起動ステータスが表示されます。
[root@tecmint ~]# chkconfig --list
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
abrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrt-oops 0:off 1:off 2:off 3:on 4:off 5:on 6:off
...
2. 特定のサービスのステータスを確認する
以下のコマンドは、特定のサービスの起動設定を示しています。すべての実行レベルでHTTP サービスがオフになっていることを示しています。
[root@tecmint ~]# chkconfig --list | grep httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
3. 実行レベルで特定のサービスを開始するにはどうすればよいですか
次の 'chkconfig' コマンドは、' を使用して実行レベル 3 および 5 でのみ HTTP サービスを開始する方法を示しています。 「–レベル」パラメータ。最初のコマンドは実行レベル 3 および 5 で httpd サービスを開始し、2 番目のコマンドは実行中の httpd サービスのステータスを確認します。実行レベル。
[root@tecmint ~]# chkconfig --level 35 httpd on
[root@tecmint ~]# chkconfig --list | grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
4. オン/オフのサービスを確認する方法
次のコマンドは、特定の実行レベル 5 でオンとオフになっているすべてのサービスを表示します。
[root@tecmint ~]# chkconfig --list | grep 5:on
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
abrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrt-oops 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
...
[root@tecmint ~]# chkconfig --list | grep 5:off
dnsmasq 0:off 1:off 2:off 3:off 4:off 5:off 6:off
dovecot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
firstboot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
kdump 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
...
5. 実行レベルで特定のサービスを停止するにはどうすればよいですか
次のコマンドは、 単一の実行レベルに対してpostfix と呼ばれるサービスをオフにします。同様に、以下に示すように、複数の実行レベルで特定のサービスを一度にオフにすることができます。
[root@tecmint ~]# chkconfig --level 3 postfix off
[root@tecmint ~]# chkconfig --level 2345 postfix off
ご存知のとおり、Linux オペレーティング システムでは 7 つの実行レベルが利用可能です。さまざまな実行レベルと起動シーケンスの重要性については、今後の記事で詳しく説明します。どうぞご期待ください。