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++
- 下一篇: 句柄与指针的区别