Systemd基础篇:systemd vs SysVinit
生活随笔
收集整理的这篇文章主要介绍了
Systemd基础篇:systemd vs SysVinit
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
Systemd已经基本取代了SysV的Init,这篇文章从几个方面整理一下Systemd与Init的使用上的区别。
命令比较: SysVinit vs Systemd
| 服务启动 | service 服务名 start | systemd start 服务名.service (.service可省略,后同) |
| 服务停止 | service 服务名 stop | systemctl stop 服务名 |
| 服务重启 | service 服务名 restart | systemctl restart 服务名 |
| 服务重新加载 | service 服务名 reload | systemctl reload 服务名 |
| 服务状态确认 | service 服务名 status | systemctl status 服务名 |
| 服务开机启动设定 | chkconfig 服务名 on | systemctl enable 服务名 |
| 取消服务开机启动设定 | chkconfig service off | systemctl disable 服务名 |
| 确认服务开机启动设定状态 | chkconfig 服务名 | systemctl is-enabled 服务名 |
| 加载服务配置文件 | chkconfig 服务名 -add | systemctl deamon-reload |
| 关机 | halt | systemctl halt |
| 关机(电源) | poweroff | systemctl poweroff |
| 重启 | reboot | systemctl reboot |
| 休眠 | pm-hibernate | systemctl hibernate |
| 挂起 | pm-suspend | systemctl suspend |
RunLevel: SysVinit vs Systemd
| System halt | 0 | runlevel0.target, poweroff.target |
| Single user mode | 1 | runlevel1.target, rescure.target |
| Multi user | 2 | runlevel02target, multi-user.target |
| Multi user with network | 3 | runlevel3.target, multi-user.target |
| Experimental | 4 | runlevel4.target, multi-user.target |
| Multi user with network, graphical mode | 5 | runlevel5.target, graphical.target |
| Reboot | 6 | runlevel6.target, reboot.target |
日志确认方式
SysVinit方式
- 确认系统日志文件
文件名: /var/log/message
文件名:/var/log/syslog
Systemd
- 确认系统日志信息
使用命令: journalctl -f
- 确认某一时间点之后的日志信息
使用命令:journalctl -since=xxx
Systemd特殊命令
确认启动时间
使用命令:systemd-analyze 或者 systemd-analyze time
[root@host ~]# systemd-analyze Startup finished in 1.638s (kernel) + 1.951s (initrd) + 14.177s (userspace) = 17.767s [root@host ~]# [root@host ~]# systemd-analyze time Startup finished in 1.638s (kernel) + 1.951s (initrd) + 14.177s (userspace) = 17.767s [root@host ~]#停止服务相关进程
使用命令:systemctl kill 服务名
hostname设定
使用命令:hostnamectl
[root@host shell]# hostnamectlStatic hostname: host.localdomainIcon name: computer-vmChassis: vmMachine ID: d27a659b15fc379d24204584d5c051bdBoot ID: 3fe84ed9506248b9a41c492ca543748aVirtualization: kvmOperating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 4.10.4-1.el7.elrepo.x86_64Architecture: x86-64 [root@host shell]# [root@host shell]# [root@host shell]# hostnamectl set-hostname liumiaocn [root@host shell]#再次登录之后,hostname的变化即可看到
[root@liumiaocn ~]#时间设定
使用命令: timedatectl
注:使用方法可参看:
- https://liumiaocn.blog.csdn.net/article/details/88408155
管理login:loginctrl
使用例:查看当前登录用户的Session状况
[root@liumiaocn ~]# loginctlSESSION UID USER SEAT 10 0 root 1 sessions listed. [root@liumiaocn ~]#管理locale:localectl
使用例:查看当前本地化设定信息
[root@liumiaocn ~]# localectlSystem Locale: LANG=en_US.UTF-8VC Keymap: usX11 Layout: us [root@liumiaocn ~]#总结
以上是生活随笔为你收集整理的Systemd基础篇:systemd vs SysVinit的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: libSVM分类小例C++
- 下一篇: 句柄与指针的区别