前言
从centos 7开始,好多在centos 6 版本总常用的命令都发生了改变,本文章中讲解一些两者主要的区别,让大家在学习或工作中好区别两者。
System V init和systemd 初始化进程
centos 6 中使用System V init进程来完成系统开机时的各项初始化工作,而在centos 7版本中,使用全新的systemd 进程来完成开机初始化,其开机速度得到了不小的提升。
运行级别和.target
centos 6 版本中使用System V init进程,所以其运行级别是 init 0-init 6
,通过init 来切换不同的系统运行级别,在/etc/inittab
文件最后一行配置默认的运行级别,而在centos 7 版本中抛弃了运行级别这个概念,转而使用 systemd 目标(.target)
代替,下面就是两者的区别:
| System V init运行级别,对应命令|systemd目标名称,对应命令|作用 |
| 0 init 0 | poweroff.target systemctl isolate poweroff.target | 关机
| 1 init 1 | rescue.target systemctl isolate rescue.target | 单用户模式
| 2 init 2 | 无 无 | 无
| 3 init 3 | multi-user.target systemctl isolate multi-user.target| 完全多用户模式
| 4 系统保留 | 系统保留 无 | 无
| 5 init 5 | graphical.target systemctl isolate graphical.target | 图形化界面
| 6 init 6 | reboot.target systemctl isolate reboot.target | 重启
服务管理命令service chkconfig和systemctl
centos 6版本管理服务使用service 命令来管理,chkconfig来实现开机自启,而在centos 7版本之后使用systemctl命令来管理服务了,如下所示:
service httpd start #centos 6版本下启动httpd服务
chkconfig --level 3 httpd on #centos 6版本设置httpd在3运行级别下开机自启动
systemctl start httpd.service #centos 7版本下启动httpd服务
systemctl enable httpd.service #centos 7版本下开机自启动httpd服务