学习啦 > 学习电脑 > 操作系统 > Linux教程 > linux systemctl命令详解

linux systemctl命令详解

时间: 佳洲1085 分享

学习啦在线学习网linux systemctl命令详解

  systemctl命令是Linux下的一个命令,那么它具体语法是什么呢?下面由学习啦小编为大家整理了linux systemctl命令的相关知识,希望对大家有帮助!

  linux systemctl命令说明

学习啦在线学习网   systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

  linux systemctl命令格式

  systemctl is-enabled iptables.service #查询服务是否开机启动

  systemctl enable *.service #开机运行服务

  systemctl disable *.service #取消开机运行

学习啦在线学习网   systemctl start *.service #启动服务

学习啦在线学习网   systemctl stop *.service #停止服务

  restart *.service #重启服务

  systemctl reload *.service #重新加载服务配置文件

  systemctl status *.service #查询服务运行状态

  systemctl --failed #显示启动失败的服务

  systemctl list-unit-files --type=service #列出所有服务(包括启用的和禁用的)

  systemctl mask *.service #屏蔽(让它不能启动) s

学习啦在线学习网   ystemctl unmask *.service #显示服务

  linux systemctl命令实例

学习啦在线学习网   1.启动nfs服务

  systemctl start nfs-server.service

学习啦在线学习网   2.设置开机自启动

学习啦在线学习网   systemctl enable nfs-server.service

  3.停止开机自启动

学习啦在线学习网   systemctl disable nfs-server.service

学习啦在线学习网   4.查看服务当前状态

学习啦在线学习网   systemctl status nfs-server.service

  5.重新启动某服务

学习啦在线学习网   systemctl restart nfs-server.service

  6.查看所有已启动的服务

  systemctl list -units --type=service

学习啦在线学习网   7.开启防火墙22端口

  iptables -I INPUT -p tcp --dport 22 -j accept

学习啦在线学习网   如果仍然有问题,就可能是SELinux导致的

学习啦在线学习网   关闭SElinux: 修改/etc/selinux/config文件中的SELINUX=””为disabled,然后重启。

学习啦在线学习网   彻底关闭防火墙:

学习啦在线学习网   sudo systemctl status firewalld.service

  sudo systemctl stop firewalld.service

  sudo systemctl disable firewalld.service

3582317