CentOS7中systemctl命令详解
发布日期:2021-10-04 02:53:39
浏览次数:6
分类:技术文章
本文共 2284 字,大约阅读时间需要 7 分钟。
Linux Systemctl是一个系统管理守护进程、工具和库的集合,用于取代System V、service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器。通过Systemctl –help可以看到该命令主要分为:查询或发送控制命令给systemd服务,管理单元服务的命令,服务文件的相关命令,任务、环境、快照相关命令,systemd服务的配置重载,系统开机关机相关的命令。
- 列出所有可用单元
systemctl list-unit-files
- 列出所有运行中单元
systemctl list-units
- 列出所有失败单元
systemctl –failed
- 检查某个单元(如 crond.service)是否启用
systemctl is-enabled crond.service
- 列出所有服务
systemctl list-unit-files –type=service
- Linux中如何启动、重启、停止、重载服务以及检查服务(如 httpd.service)状态
systemctl start httpd.servicesystemctl restart httpd.servicesystemctl stop httpd.servicesystemctl reload httpd.servicesystemctl status httpd.service
注意:当我们使用systemctl的start,restart,stop和reload命令时,终端不会输出任何内容,只有status命令可以打印输出。
- 如何激活服务并在开机时启用或禁用服务(即系统启动时自动启动mysql.service服务)
systemctl is-active mysql.servicesystemctl enable mysql.servicesystemctl disable mysql.service
- 如何屏蔽(让它不能启动)或显示服务(如ntpdate.service)
systemctl mask ntpdate.serviceln -s /dev/null /etc/systemd/system/ntpdate.servicesystemctl unmask ntpdate.servicerm /etc/systemd/system/ntpdate.service
- 使用systemctl命令杀死服务
systemctl kill crond
- 列出所有系统挂载点
systemctl list-unit-files –type=mount
11. 挂载、卸载、重新挂载、重载系统挂载点并检查系统中挂载点状态systemctl start tmp.mountsystemctl stop tmp.mountsystemctl restart tmp.mountsystemctl reload tmp.mountsystemctl status tmp.mount
- 在启动时激活、启用或禁用挂载点(系统启动时自动挂载)
systemctl is-active tmp.mountsystemctl enable tmp.mountsystemctl disable tmp.mount
- 在Linux中屏蔽(让它不能启用)或可见挂载点
systemctl mask tmp.mountln -s /dev/null /etc/systemd/system/tmp.mountsystemctl unmask tmp.mountrm /etc/systemd/system/tmp.mount
- 列出所有可用系统套接口
systemctl list-unit-files –type=socket
- 检查某个服务的所有配置细节
systemctl show mysql
- 获取某个服务(httpd)的依赖性列表
systemctl list-dependencies httpd.service
- 启动救援模式
systemctl rescue
- 进入紧急模式
systemctl emergency
- 列出当前使用的运行等级
systemctl get-default
- 启动运行等级5,即图形模式
systemctl isolate runlevel5.target
或
systemctl isolate graphical.target
- 启动运行等级3,即多用户模式(命令行)
systemctl isolate runlevel3.target
或
systemctl isolate multiuser.target
- 设置多用户模式或图形模式为默认运行等级
systemctl set-default runlevel3.targetsystemctl set-default runlevel5.target
- 重启、停止、挂起、休眠系统或使系统进入混合睡眠
systemctl rebootsystemctl haltsystemctl suspendsystemctl hibernatesystemctl hybrid-sleep
对于不知运行等级为何物的人,说明如下。
Runlevel 0 : 关闭系统Runlevel 1 : 救援,维护模式Runlevel 3 : 多用户,无图形系统Runlevel 4 : 多用户,无图形系统Runlevel 5 : 多用户,图形化系统Runlevel 6 : 关闭并重启机器
转载地址:https://blog.csdn.net/leifeng_001/article/details/70339046 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月15日 19时53分01秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
将《 两周自制脚本语言 》测试中使用的接口中文化
2021-06-29
5分钟入门LingaScript-尝鲜中文版TypeScript
2019-04-26
重拾《 两周自制脚本语言 》- 支持中文标识符
2019-04-26
Java实现文本编辑时基于拼音输入的补全原型
2019-04-26
从立创EDA,Gratipay看中文编程开发环境和推广运营的一个趋势
2019-04-26
中文代码之Django官方入门:建立模型
2019-04-26
Python实现推流直播
2019-04-26
你不得不了解的卷积神经网络发展史
2019-04-26
你不得不了解的机器学习知识
2019-04-26
你不得不了解的深度学习知识(一)
2019-04-26
你不得不了解的深度学习知识(二)
2019-04-26
AI算法之Encoder-Decoder 和 Seq2Seq
2019-04-26
AI算法之Attention机制
2019-04-26
人体口罩佩戴检测实战
2019-04-26
[YoLoV3目标检测实战] keras+yolov3训练自身口罩检测数据集
2019-04-26
[实战]200类鸟类细粒度图像分类
2019-04-26
【实战】英文垃圾短信分类
2019-04-26
FFmpeg初遇见_基本命令
2019-04-26