天天看点

Linux--system的命令 服务状态

一、systemd

系统初始化程序,系统开始的第一个进程,pid为1

图示:systemd系统初始程序

<a href="https://s1.51cto.com/wyfs02/M00/A6/DE/wKioL1ncxD7hCXEiAAFOnMthqrQ236.png-wh_500x0-wm_3-wmp_4-s_3312565531.png" target="_blank"></a>

二、systemctl 命令

systemctl list-units            ##列出当前系统服务的状态,具体祥解见三服务状态

图示:当前系统服务状态

<a href="https://s1.51cto.com/wyfs02/M01/08/2C/wKiom1ndM12zVvE9AADcY_EobGY580.png-wh_500x0-wm_3-wmp_4-s_810381615.png" target="_blank"></a>

systemctl list-unit-files        ##列出服务的开机状态

图示:服务开机状态

<a href="https://s3.51cto.com/wyfs02/M02/08/2C/wKiom1ndM2_gAaKoAADe1bS8c8U533.png-wh_500x0-wm_3-wmp_4-s_3685885002.png" target="_blank"></a>

systemctl status sshd            ##查看指定服务的状态

Loaded:【已加载】

Active:【可以使用的,正在运行】

Main PID:【执行的ID】

CGroup:【位置】

执行历史

图示:查看sshd服务的状态

<a href="https://s1.51cto.com/wyfs02/M02/A6/DE/wKioL1ncxIrhXbRSAAC-DoLd-mU678.png-wh_500x0-wm_3-wmp_4-s_1828633141.png" target="_blank"></a>

systemctl stop sshd             ##关闭指定服务

图示:关闭sshd服务,并查看sshd状态

<a href="https://s3.51cto.com/wyfs02/M00/08/2C/wKiom1ndM7GiEdoHAADxGdzAKpw982.png-wh_500x0-wm_3-wmp_4-s_1375894865.png" target="_blank"></a>

systemctl start sshd             ##开启指定服务

图示:开启sshd服务,并查看sshd状态

<a href="https://s5.51cto.com/wyfs02/M00/A6/DE/wKioL1ncxLWzrRiHAADWjxjsvbc440.png-wh_500x0-wm_3-wmp_4-s_699105714.png" target="_blank"></a>

systemctl restart sshd            ##重新启动服务

图示:重新启动sshd服务,并查看sshd状态

<a href="https://s1.51cto.com/wyfs02/M01/08/2C/wKiom1ndM9fwW31SAADiroqVg5M156.png-wh_500x0-wm_3-wmp_4-s_2342629468.png" target="_blank"></a>

systemctl enable sshd            ##设定指定服务开机开启

图示:设定sshd服务开机自启,并查看ssdhd状态

<a href="https://s2.51cto.com/wyfs02/M01/A6/DE/wKioL1ncxNnApuNdAADCF0QjcRk336.png-wh_500x0-wm_3-wmp_4-s_478637657.png" target="_blank"></a>

systemctl disable sshd            ##设定指定服务开机关闭

图示:设定sshd服务开机不自启,并查看ssdhd状态

<a href="https://s2.51cto.com/wyfs02/M01/08/2C/wKiom1ndM_nC2ZziAADG1EpnKNc642.png-wh_500x0-wm_3-wmp_4-s_2203336179.png" target="_blank"></a>

systemctl reload sshd            ##使指定服务从新加载配置

图示:重新加载sshd服务的配置,并查看ssdhd状态

<a href="https://s4.51cto.com/wyfs02/M01/A6/DE/wKioL1ncxP2SVufQAAE0vVvZvY8684.png-wh_500x0-wm_3-wmp_4-s_3179392086.png" target="_blank"></a>

systemctl list-dependencies sshd    ##查看指定服务的依赖关系

示图:查看sshd服务的依赖关系

<a href="https://s1.51cto.com/wyfs02/M01/A6/DE/wKioL1ncxTOwXexEAACuIhjPCfw010.png-wh_500x0-wm_3-wmp_4-s_2002509863.png" target="_blank"></a>

systemctl mask    sshd            ##冻结指定服务

图示:冻结sshd服务,并查看ssdhd状态

<a href="https://s3.51cto.com/wyfs02/M02/08/2C/wKiom1ndNFPjszqsAAEXWWgY1PA378.png-wh_500x0-wm_3-wmp_4-s_274361928.png" target="_blank"></a>

systemctl unmask sshd            ##启用服务

图示:启用sshd服务,并查看ssdhd状态

<a href="https://s5.51cto.com/wyfs02/M00/A6/DE/wKioL1ncxW2iGt2jAAEmUyAACDM316.png-wh_500x0-wm_3-wmp_4-s_4276051751.png" target="_blank"></a>

systemctl set-default multi-user.target    ##开机不开启图形,可重启查看

图示:开机开启图形

<a href="https://s1.51cto.com/wyfs02/M00/A6/DE/wKioL1ncxcDQUfy1AABQuaBmL7E299.png-wh_500x0-wm_3-wmp_4-s_122949990.png" target="_blank"></a>

systemctl set-default graphical.target    ##开机启动图形

setterm                    ##文本界面设定color

三、服务状态

systemctl     status        服务名称

loaded                ##系统服务已经初始化完成,加载过配置

active(running)        ##正有一个或多个程序正在系统中执行,

                # vsftpd 就是這種模式

atcive(exited)        ##僅執行一次就正常結束的服務,

                # 目前並沒有任何程序在系統中執行

atcive(waiting)        ##正在執行當中,

                # 不過還再等待其他的事件才能繼續處理

inactive            ##服务关闭

enbaled                ##服务开机启动

disabled            ##服务开机不自启

static                ##服务开机启动项不可被管理

failed                ##系统配置错误

本文转自 無緣 51CTO博客,原文链接:http://blog.51cto.com/13352594/1975407

继续阅读