(八)systemctl命令

33 阅读1分钟

systemctl命令

Linux系统很多软件(内置或第三方)均支持使用systemctl命令控制:启动、停止、开机自启

能够被systemctl管理的软件,一般也称为:服务

 systemctl start | stop | status | enable | disable 服务名

系统内置的服务比较多,比如:

  • NetworkManager,主网络服务
  • network,副网络服务
  • firewalld,防火墙服务
  • sshd,ssh服务(FinalShell远程登录Linux使用的就是这个服务)

现在可以使用systemctl去尝试一下,控制这些服务的启动、关闭、自启动等

查看防火墙

image.png

暂停防火墙

 systemctl stop firewalld

image.png

启动防火墙

 systemctl start firwalld

image.png

开机启动/关闭防火墙

 systemctl enable/disable firewalld

image.png

image.png

image.png

第三方软件控制系统

除了内置的服务意外,部分第三方软件安装后也可以以systemctl进行控制

  • yum install -y ntp,安装ntp软件

    可以通过ntpd服务名,配合systemctl进行控制

  • yum install -y httpd,安装apache服务器软件

    可以通过httpd服务名,配合systemctl进行控制

 #安装ntp
 yum install -y ntp
 ​
 #查看ntp状态
 systemctl status ntpd
 ​
 #开机启动ntp
 systemctl enable ntpd
 # 安装httpd
 yum -y install httpd
 ​
 #查看httpd状态
 systemctl status httpd
 ​
 #启动httpd
 systemctl start httpd

部分软件安装后没有自动集成到systemctl中,我们可以手动添加。