管理服務vim
命令格式:systemctl COMMAND name.service
注意:如下name.service表示某個具體服務app
啓動:service name start ==> systemctl start name.service
中止:service name stop ==> systemctl stop name.service
重啓:service name restart ==> systemctl restart name.service
狀態:service name status ==> systemctl status name.service
條件式重啓:已啓動才重啓,不然不作操做: service name cond restart ==> systemctl try-restart name.service
重載或重啓服務:先加載,再啓動: systemctl reload-or-restart name.service
重載或條件式重啓服務:systemctl reload-or-try-restart name.service
禁止自動和手動啓動:systemctl mask name.service
取消禁止:systemctl unmask name.service
服務查看ssh
##查看 某服務當前激活與否的狀態: systemctl is-active name.service
##查看全部已經激活的服務: systemctl list-units --type|-t service
##查看全部服務: systemctl list-units --type service -a
服務狀態ide
systemctl list-units --type service --all 顯示狀態
loaded:Unit 配置文件已處理
active(running): 一次或屢次持續處理的運行
active(exited): 成功完成一次性的配置
active(waiting): 運行中,等待一個事件
inactive: 不運行
enabled: 開機啓動
disabled: 開機不啓動
static:開機不啓動,但可被另外一個啓用的服務激活
殺掉進程ui
systemctl kill 進程名
chkconfig命令的對應關係spa
設定某服務開機自啓:
chkconfig name on ==> systemctl enable name.service
設定某服務開機禁止啓動:
chkconfig name off ==> systemctl disable name.service
查看全部服務的開機自啓狀態:
chkconfig --list ==> systemctl list-unit-files --type service
用來列出該服務在哪些運行級別下啓用和 禁用rest
chkconfig sshd –list ==> ls /etc/systemd/system/*.wants/sshd.service
[root@localhost ~]# ls /etc/systemd/system/*.wants/sshd.service
/etc/systemd/system/multi-user.target.wants/sshd.service
查看服務是否開機自啓:code
systemctl is-enabled name.service
[root@localhost ~]# systemctl is-enabled sshd.service
enabled
查看服務的依賴關係:regexp
systemctl list-dependencies name.service
運行級別
orm
unit 配置文件:.target
ls /usr/lib/systemd/system/*.target
systemctl list-unit-files --type target --all //查看級別
查看依賴性:
systemctl list-dependencies graphical.target //查看級別的依賴性