Systemctl 和 service 命令的区别 [英] Difference between Systemctl and service command
问题描述
我总是以这种方式运行我的 Apache 服务器:
I always run my Apache server in this way:
sudo service apache2 start
但在许多指南中我看到了这样的命令:
But in many guides I saw commands like this:
sudo systemctl start apache2
有人可以简短地写出这些命令之间的区别,并就我在日常工作中应该使用什么命令给我建议吗?
Can somebody shortly write the difference between these commands and give me advice about what command I should use in everyday work?
推荐答案
service
对 /etc/init.d 中的文件进行操作,并与旧的初始化系统.systemctl
对 /lib/systemd 中的文件进行操作.如果 /lib/systemd 中有您的服务的文件,它将首先使用该文件,如果没有,它会退回到 /etc/init.d 中的文件.另外,如果您使用的是像 ubuntu-14.04 这样的操作系统,则只能使用 service 命令.
service
operates on the files in /etc/init.d and was used in conjunction with the old init system. systemctl
operates on the files in /lib/systemd. If there is a file for your service in /lib/systemd it will use that first and if not it will fall back to the file in /etc/init.d.
Also If you are using OS like ubuntu-14.04 only service command will be available.
所以如果 systemctl 可用,最好使用它
So if systemctl is available ,it will be better to use it
这篇关于Systemctl 和 service 命令的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!