Systemctl和服务命令之间的区别 [英] Difference between Systemctl and service command

查看:125
本文介绍了Systemctl和服务命令之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是以这种方式运行我的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中的文件进行操作,并与旧的init系统结合使用. 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和服务命令之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆