Red Hat/CentOS中查看所有服务和正在运行的服务

Red Hat/CentOS中查看所有服务和正在运行的服务

基于Systemd的系统使用systemctl命令:适用于 Fedora Linux v22/23/24/26/27/28/29/30/31CentOS/RHEL 7.0 /8.0

列出正在运行的服务systemctl

systemctl | more

systemctl | grep httpd

systemctl list-units --type service

systemctl list-units --type mount

列出所有服务systemctl list-unit-files

查看与特定服务(cgroup)关联的进程systemd-cgtop

输出示例:

Path Tasks %CPU Memory Input/s Output/s

/ 211 2.5 817.5M - -

/system.slice/ModemManager.service 1 - - - -

/system.slice/NetworkManager.service 2 - - - -

/system.slice/abrt-oops.service 1 - - - -

/system.slice/abrt-xorg.service 1 - - - -

/system.slice/abrtd.service 1 - - - -

/system.slice/accounts-daemon.service 1 - - - -

在CentOS/RHEL 7.x +上列出SysV服务chkconfig --list

如何使用systemd检查服务状态检查sshd的状态

$ systemctl status sshd.service

确认服务状态检查服务是否正在运行

systemctl is-active sshd

systemctl is-enabled sshd

systemctl is-active nginx

systemctl is-enabled nginx

systemctl is-enabled httpd

在RHEL/CentOS 8.x查看服务列出当前加载的服务:

$ sudo systemctl list-units --type=service

显示已加载的和活动的单元/服务:

$ sudo systemctl

使用grep命令/egrep命令过滤掉:

$ sudo systemctl | egrep 'httpd|php-fpm|mysqld|nginx'

$ sudo systemctl list-units --type=service | grep nginx

查看服务/单元的依赖关系# systemctl list-dependencies {service-name}

# systemctl list-dependencies nginx.service

# systemctl list-dependencies php-fpm.service

# systemctl list-dependencies sshd.service

# systemctl list-dependencies crond.service

✨ 相关推荐

泰铢汇率,泰币兑人民币汇率
下载旧版本彩票365软件

泰铢汇率,泰币兑人民币汇率

📅 07-11 👀 9373
新品牌新风向 塔盾NO.11新品机箱详评(全文)
下载旧版本彩票365软件

新品牌新风向 塔盾NO.11新品机箱详评(全文)

📅 09-23 👀 3909
皓予名字寓意解析
下载旧版本彩票365软件

皓予名字寓意解析

📅 11-01 👀 4827