chkconfigの使い方
chkconfigは/etc/init.dに登録されたサービスの自動起動を管理するコマンド。
なんどやっても覚えないのでまとめとく。
サービスの一覧
登録されているサービスを表示するには--listを指定する。(と言っても省略可)
サービス毎にどのランレベルで起動するかを示している。
$ chkconfig --list # もしくはchkconfig NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off bluetooth 0:off 1:off 2:off 3:on 4:on 5:on 6:off cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off …
サービス名を指定すれば、そのサービスだけ表示できる。(この場合--listは必須)
$ chkconfig --list crond crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
サービスの自動起動を変更
sshdサービスの自動起動をON
# chkconfig sshd on
レベルを指定してONにする場合は
# chkconfig --level 35 sshd on # ランレベルが3か5の場合に起動する
sshdサービスの自動起動をOFF
# chkconfig sshd off
サービスの追加・削除
パッケージを利用してると、大抵は追加されているので実行したことないけど
自動起動するサービスを追加・削除できる。
sshdサービスを追加
# chkconfig --add sshd
sshdサービスを削除
# chkconfig --del sshd
ちなみに
ランレベル毎にサービスを起動するかどうかは、/etc/rc(ランレベル).d/以下のシンボリックリンクで決まる。
$ ls -l /etc/rc*.d/*crond lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc0.d/K60crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc1.d/K60crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc2.d/S90crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc3.d/S90crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc4.d/S90crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc5.d/S90crond -> ../init.d/crond* lrwxrwxrwx. 1 root root 15 2010-04-20 02:08 /etc/rc6.d/K60crond -> ../init.d/crond*
chkconfigはこのシンボリックリンクを編集しているようだ。
Kで始まるシンボリックリンクがOFFで、Sで始まるのがONってことね。