在Ubuntu中没有chkconfig命令

总结

由于启动环境中没有chkconfig,因此做出了相关的备忘录。

事态

当我运行chkconfig命令时,系统告诉我没有找到。

$ sudo chkconfig apache2 on
sudo: chkconfig: command not found

环境

通过Vagrant构建的Ubuntu

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.6 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.6 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

处理

用以下命令替代

检查服务状态。

我没有查看服务状态的能力,因此通过ls来确认。

$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 10 16:55 /etc/rc6.d/K09apache2 -> ../init.d/apache2

在上述中,使用等级2、3、4、5来启动,使用0、1、6来停止。

在指定的跑步等级停下来

$ sudo update-rc.d apache2 disable 2 3 4 5
update-rc.d: warning:  start runlevel arguments (none) do not match apache2 Default-Start values (2 3 4 5)
update-rc.d: warning:  stop runlevel arguments (none) do not match apache2 Default-Stop values (0 1 6)
 Disabling system startup links for /etc/init.d/apache2 ...
 Removing any system startup links for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2
   /etc/rc1.d/K09apache2
   /etc/rc2.d/S91apache2
   /etc/rc3.d/S91apache2
   /etc/rc4.d/S91apache2
   /etc/rc5.d/S91apache2
   /etc/rc6.d/K09apache2
 Adding system startup for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2 -> ../init.d/apache2
   /etc/rc1.d/K09apache2 -> ../init.d/apache2
   /etc/rc6.d/K09apache2 -> ../init.d/apache2
   /etc/rc2.d/K09apache2 -> ../init.d/apache2
   /etc/rc3.d/K09apache2 -> ../init.d/apache2
   /etc/rc4.d/K09apache2 -> ../init.d/apache2
   /etc/rc5.d/K09apache2 -> ../init.d/apache2

# 確認
$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc2.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc3.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc4.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc5.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:03 /etc/rc6.d/K09apache2 -> ../init.d/apache2

以指定的运行级别启动

$ sudo update-rc.d apache2 enable 2 3 4 5
update-rc.d: warning:  start runlevel arguments (none) do not match apache2 Default-Start values (2 3 4 5)
update-rc.d: warning:  stop runlevel arguments (none) do not match apache2 Default-Stop values (0 1 6)
 Enabling system startup links for /etc/init.d/apache2 ...
 Removing any system startup links for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2
   /etc/rc1.d/K09apache2
   /etc/rc2.d/K09apache2
   /etc/rc3.d/K09apache2
   /etc/rc4.d/K09apache2
   /etc/rc5.d/K09apache2
   /etc/rc6.d/K09apache2
 Adding system startup for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2 -> ../init.d/apache2
   /etc/rc1.d/K09apache2 -> ../init.d/apache2
   /etc/rc6.d/K09apache2 -> ../init.d/apache2
   /etc/rc2.d/S91apache2 -> ../init.d/apache2
   /etc/rc3.d/S91apache2 -> ../init.d/apache2
   /etc/rc4.d/S91apache2 -> ../init.d/apache2
   /etc/rc5.d/S91apache2 -> ../init.d/apache2

# 確認
$ ls -l /etc/rc*.d/*apache*
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc0.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc1.d/K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 May 11 02:04 /etc/rc6.d/K09apache2 -> ../init.d/apache2

请参考。

https://gist.github.com/koudaiii/dae08d3cb9c861a1d4b3 https://server-setting.info/debian/debian-like-chkconfig.html 的中文翻译:

广告
将在 10 秒后关闭
bannerAds