一 .systemctl 命令
1.1 网络服务
#启动网络服务 systemctl start firewalld.service #停止网络服务 systemctl stop firewalld.service #重启网络服务 systemctl restart firewalld.service #查看网络服务状态 systemctl status firewalld.service
1.2 设置开机启动/不启动
#停止cup电源管理服务 systemctl stop cups.service #禁止cups服务开机启动 systemctl disable cups.service #查看cups服务状态 systemctl status cups.service #重新设置cups服务开机启动 systemctl enable cups.service
1.3查看系统上上所有的服务
#列出所有启动unit systemctl list-units #列出所有启动文件 systemctl list-unit-files #列出所有service类型的unit systemctl list-units –type=service –all #列出 cpu电源管理机制的服务 systemctl list-units –type=service –all grep cpu #列出所有target systemctl list-units –type=target –all
1.4 systemctl特殊的用法
#查看网络服务是否启动 systemctl is-active network.service #检查网络服务是否设置为开机启动 systemctl is-enable network.service #停止cups服务 systemctl stop cups.service #注销cups服务 systemctl mask cups.service #查看cups服务状态 systemctl status cups.service #取消注销cups服务 systemctl unmask cups.service
1.5 开关机相关的其他命令
#进入睡眠模式 systemctl suspend #进入休眠模式 systemctl hibernate #强制进入救援模式 systemctl rescue #强制进入紧急救援模式 systemctl emergency
1.6 设置运行级别
#获得当前的运行级别 systemctl get-default #设置默认的运行级别为mulit-user systemctl set-default multi-user.target #在不重启的情况下,切换到运行级别mulit-user下 systemctl isolate multi-user.target #在不重启的情况下,切换到图形界面下 systemctl isolate graphical.target
1.7 关闭防火墙firewall
systemctl stop firewalld.service systemctl disable firewalld.service