日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Systemd基础篇:systemd vs SysVinit

發布時間:2023/12/20 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Systemd基础篇:systemd vs SysVinit 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


Systemd已經基本取代了SysV的Init,這篇文章從幾個方面整理一下Systemd與Init的使用上的區別。

命令比較: SysVinit vs Systemd

命令用途SysVInit命令Systemd命令
服務啟動service 服務名 startsystemd start 服務名.service (.service可省略,后同)
服務停止service 服務名 stopsystemctl stop 服務名
服務重啟service 服務名 restartsystemctl restart 服務名
服務重新加載service 服務名 reloadsystemctl reload 服務名
服務狀態確認service 服務名 statussystemctl status 服務名
服務開機啟動設定chkconfig 服務名 onsystemctl enable 服務名
取消服務開機啟動設定chkconfig service offsystemctl disable 服務名
確認服務開機啟動設定狀態chkconfig 服務名systemctl is-enabled 服務名
加載服務配置文件chkconfig 服務名 -addsystemctl deamon-reload
關機haltsystemctl halt
關機(電源)poweroffsystemctl poweroff
重啟rebootsystemctl reboot
休眠pm-hibernatesystemctl hibernate
掛起pm-suspendsystemctl suspend

RunLevel: SysVinit vs Systemd

RunLevelSysVInitSystemd
System halt0runlevel0.target, poweroff.target
Single user mode1runlevel1.target, rescure.target
Multi user2runlevel02target, multi-user.target
Multi user with network3runlevel3.target, multi-user.target
Experimental4runlevel4.target, multi-user.target
Multi user with network, graphical mode5runlevel5.target, graphical.target
Reboot6runlevel6.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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。