init,service和systemctl的区别

参考http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

1、service是一个脚本命令,分析service可知是去/etc/init.d目录下执行相关程序。service和chkconfig结合使用。
服务配置文件存放目录/etc/init.d/

例如

# 启动sshd服务
service sshd start
# 设置sshd服务开机启动
chkconfig sshd start
1
2
3
4
2、systemd
centos7版本中使用了systemd,systemd同时兼容service,对应的命令就是systemctl
Systemd 是 Linux 系统中最新的初始化系统(init),它主要的设计目标是克服 sysvinit 固有的缺点,提高系统的启动速度
使用systemd的目的是获取更快的启动速度。
为了减少系统启动时间,systemd的目标是
尽可能启动较少的进程
尽可能将更多进程并发启动
可以去查看系统进程的pid,initd的pid是0,如果支持systemd的系统的systemd进程pid为1

systemd把不同的资源称为Unit
每一个 Unit 都有一个配置文件,告诉 Systemd 怎么启动这个 Unit
存放目录:/etc/systemd/system和/usr/lib/systemd/system

对于有先后依赖关系的任务
systemctl融合service和chkconfig功能
systemctl的使用例如

# 开启服务
systemctl start sshd.service
# 设置开机启动
systemctl enable sshd.service
# 本质上是建立一个软链接 ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service
1
2
3
4
5
转载自
http://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/
Systemd 的使用
---------------------

原文:https://blog.csdn.net/lineuman/article/details/52578399

posted on 2018-11-19 15:18  szllq2000  阅读(522)  评论(0编辑  收藏  举报