一、系统服务的控制

  1.systemd

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

  2.systemctl 命令

  systemctl  list-units   ##列出当前系统服务的状态

  萌新的Linux学习之路(七)

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

   萌新的Linux学习之路(七)

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

   systemctl stop sshd          ##关闭指定服务

   systemctl start  sshd        ##开启指定服务

   systemctl  restart  sshd      ##从新启动服务

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

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

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

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

   systemctl  mask  sshd         ##冻结指定服务

   systemctl  umask  sshd        ##启用冻结服务

    萌新的Linux学习之路(七)

    systemctl  set-default  multi-user.target  ##开机不开启图形界面

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

    3.服务状态

    systemctl         status       服务名称

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

   active(running)   ##争优一个或多个程序在系统中执行

                  ##vsftpd  就是这种模式

   active(exited)    ##仅执行一次就正常结束的服务

                  ##目前没有任何程序在系统中执行

   active(waiting)    ##正在执行当中,不过在等待其他时间才能继续处理

   

   inactive       ##服务关闭

    enabled       ##服务开机启动

   disabled       ##服务开机不自启

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

   failed        ##系统配置错误