systemctl命令 – 管理系统服务
systemctl命令来自于英文词组”system control“的缩写,其功能是用于管理系统服务。从RHEL/CentOS7版本之后初始化进程服务init被替代成了systemd服务,systemd初始化进程服务的管理是通过systemctl命令完成的,从功能上涵盖了之前service、chkconfig、init、setup等多条命令的大部分功能。
语法格式:systemctl 参数 服务
常用参数:
| start | 启动服务 |
| stop | 停止服务 |
| restart | 重启服务 |
| enable | 使某服务开机自启 |
| disable | 关闭某服务开机自启 |
| status | 查看服务状态 |
| list -units --type=service | 列举所有已启动服务 |
参考实例
启动指定的服务:
[root@linuxcool ~]# systemctl start sshd
停止指定的服务:
[root@linuxcool ~]# systemctl stop sshd
重启指定的服务:
[root@linuxcool ~]# systemctl restart sshd
查看指定服务的运行状态:
[root@linuxcool ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset>
Active: active (running) since Thu 2022-05-12 17:02:08 CST; 23s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 3015 (sshd)
Tasks: 1 (limit: 12391)
Memory: 1.5M
CGroup: /system.slice/sshd.service
└─3015 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-p>
将指定的服务加入到开机启动项中:
[root@linuxcool ~]# systemctl enable sshd
将指定的服务从开机启动项中取消:
[root@linuxcool ~]# systemctl disable sshd
显示系统中所有已启动的服务列表信息:
[root@linuxcool ~]# systemctl list-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION accounts-daemon.service loaded active running Accounts Service atd.service loaded active running Job spooling tools
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




