Fedora/RHEL/CentOS 用于 Debian/Ubuntu 的“service servicename start”的等价物是什么?

dan*_*els 5 linux debian redhat fedora service

Fedora/RHEL/CentOS 用于 Debian/Ubuntu 的“service servicename start”的等价物是什么?
我刚刚在 serverfoault 上阅读了一些关于使用 /etc/init.d/service 已过时的问题,那么 Debian 上的正确方法是什么?

Jör*_*tag 10

我不知道“正确”的方式,但我总是使用invoke-rc.d, 所以例如重新启动 MySQL:

sudo invoke-rc.d mysql restart
Run Code Online (Sandbox Code Playgroud)


kto*_*wer 8

您始终可以直接调用启动脚本(例如,/etc/init.d/foo restart)。这也适用于 RedHat 变体,尽管那里的路径略有不同(/etc/rc.d/init.d,但我相信 /etc/init.d 也是它的符号链接)。

  • 抄袭另一个问题的评论 (http://serverfault.com/questions/30701/how-to-enable-sshd-on-fedora-11),在 Fedora 上不鼓励直接调用 /etc/init.d/servicename/红帽系统。您也不一定会像使用 /sbin/service 脚本那样获得为脚本提供的相同环境(例如,在 SELinux Gentoo 上,您需要使用 `run_init` 而不是 /etc/init.d 来开始工作正确的安全上下文。 (2认同)

Raj*_*jat 5

几乎每个发行版都有 /etc/init.d/service ********** {start|restart|reload|stop}