为什么在linux中使用service命令?

blu*_*man 12 linux service

有什么区别

service apache2 restart
Run Code Online (Sandbox Code Playgroud)

/etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)

那么为什么推荐的服务命令与直接调用相应的命令相比呢?

小智 7

service命令在可预测的环境中运行init脚本:

service在尽可能可预测的环境中运行System V init脚本,删除大多数环境变量,并将当前工作目录设置为/.

来自:http://linux.die.net/man/8/service