前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux之systemctl命令

linux之systemctl命令

作者头像
入门笔记
发布2022-06-02 14:24:28
5100
发布2022-06-02 14:24:28
举报
文章被收录于专栏:入门小站

Linux 服务管理两种方式service和systemctl,systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动。systemd对应的进程管理命令是systemctl

chkconfig和systemctl命令对比

任务

旧指令

新指令

使某服务自动启动

chkconfig --level 3 httpd on

systemctl enable httpd.service

使某服务不自动启动

chkconfig --level 3 httpd off

systemctl disable httpd.service

检查服务状态

service httpd status

systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)

显示所有已启动的服务

chkconfig --list

systemctl list-units --type=service

启动服务

service httpd start

systemctl start httpd.service

停止服务

service httpd stop

systemctl stop httpd.service

重启服务

service httpd restart

systemctl restart httpd.service

重载服务

service httpd reload

systemctl reload httpd.service

实例

代码语言:javascript
复制
#停止cup电源管理服务
> systemctl stop cups.service
#禁止cups服务开机启动
> systemctl disable cups.service
#查看cups服务状态
> systemctl status cups.service
#重新设置cups服务开机启动
> systemctl enable cups.service

常用的系统命令

systemctl命令

说明

systemctl

列出所有的系统服务

systemctl list-units

列出所有启动unit

systemctl list-unit-files

列出所有启动文件

systemctl list-units –type=service –all

列出所有service类型的unit

systemctl list-units –type=service –all grep cpu

列出 cpu电源管理机制的服务

systemctl list-units –type=target –all

列出所有target

systemctl list-unit-files --type=socket

列出所有可用系统套接口

systemctl特殊的用法

systemctl命令

说明

systemctl is-active [unit type]

查看服务是否运行

systemctl is-enable [unit type]

查看服务是否设置为开机启动

systemctl mask [unit type]

注销指定服务

systemctl unmask [unit type]

取消注销指定服务

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-05-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 入门小站 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • chkconfig和systemctl命令对比
  • 实例
  • 常用的系统命令
  • systemctl特殊的用法
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档