溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么查看Linux中所有正在運(yùn)行的服務(wù)

發(fā)布時(shí)間:2021-10-22 13:45:54 來(lái)源:億速云 閱讀:209 作者:小新 欄目:系統(tǒng)運(yùn)維

小編給大家分享一下怎么查看Linux中所有正在運(yùn)行的服務(wù),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

有許多方法和工具可以查看 Linux 中所有正在運(yùn)行的服務(wù)。大多數(shù)管理員會(huì)在 System V(SysV)初始化系統(tǒng)中使用 service service-name status/etc/init.d/service-name status,而在 systemd 初始化系統(tǒng)中使用 systemctl status service-name。

以上命令可以清楚地顯示該服務(wù)是否在服務(wù)器上運(yùn)行,這也是每個(gè) Linux 管理員都該知道的非常簡(jiǎn)單和基礎(chǔ)的命令。

如果你對(duì)系統(tǒng)環(huán)境并不熟悉,也不清楚系統(tǒng)在運(yùn)行哪些服務(wù),你會(huì)如何檢查?

是的,我們的確有必要這樣檢查一下。這將有助于我們了解系統(tǒng)上運(yùn)行了什么服務(wù),以及哪些是必要的、哪些需要被禁用。

init(初始化initialization的簡(jiǎn)稱)是在系統(tǒng)啟動(dòng)期間運(yùn)行的***個(gè)進(jìn)程。init 是一個(gè)守護(hù)進(jìn)程,它將持續(xù)運(yùn)行直至關(guān)機(jī)。

大多數(shù) Linux 發(fā)行版都使用如下的初始化系統(tǒng)之一:

  • System V 是更老的初始化系統(tǒng)

  • Upstart 是一個(gè)基于事件的傳統(tǒng)的初始化系統(tǒng)的替代品

  • systemd 是新的初始化系統(tǒng),它已經(jīng)被大多數(shù)***的 Linux 發(fā)行版所采用

什么是 System V(SysV)

SysV(意即 System V) 初始化系統(tǒng)是早期傳統(tǒng)的初始化系統(tǒng)和系統(tǒng)管理器。由于 sysVinit 系統(tǒng)上一些長(zhǎng)期懸而未決的問(wèn)題,大多數(shù)***的發(fā)行版都適用于 systemd 系統(tǒng)。

什么是 Upstart 初始化系統(tǒng)

Upstart 是一個(gè)基于事件的 /sbin/init 的替代品,它控制在啟動(dòng)時(shí)的任務(wù)和服務(wù)的開(kāi)始,在關(guān)機(jī)時(shí)停止它們,并在系統(tǒng)運(yùn)行時(shí)監(jiān)控它們。

它最初是為 Ubuntu 發(fā)行版開(kāi)發(fā)的,但其是以適合所有 Linux 發(fā)行版的開(kāi)發(fā)為目標(biāo)的,以替換過(guò)時(shí)的 System-V 初始化系統(tǒng)。

什么是 systemd

systemd 是一個(gè)新的初始化系統(tǒng)以及系統(tǒng)管理器,它已成為大多數(shù) Linux 發(fā)行版中非常流行且廣泛適應(yīng)的新的標(biāo)準(zhǔn)初始化系統(tǒng)。systemctl 是一個(gè) systemd 管理工具,它可以幫助我們管理 systemd 系統(tǒng)。

方法一:如何在 System V(SysV)系統(tǒng)中查看運(yùn)行的服務(wù)

以下命令可以幫助我們列出 System V(SysV) 系統(tǒng)中所有正在運(yùn)行的服務(wù)。

如果服務(wù)很多,我建議使用文件查看命令,如 less、more 等,以便得到清晰的結(jié)果。

# service --status-all或# service --status-all | more或# service --status-all | less
abrt-ccpp hook is installedabrtd (pid  2131) is running...abrt-dump-oops is stoppedacpid (pid  1958) is running...atd (pid  2164) is running...auditd (pid  1731) is running...Frequency scaling enabled using ondemand governorcrond (pid  2153) is running...hald (pid  1967) is running...htcacheclean is stoppedhttpd is stoppedTable: filterChain INPUT (policy ACCEPT)num  target     prot opt source               destination1    ACCEPT     all      ::/0                 ::/0                state RELATED,ESTABLISHED2    ACCEPT     icmpv6    ::/0                 ::/03    ACCEPT     all      ::/0                 ::/04    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:805    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:216    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:227    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:258    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:20829    ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:208610   ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:208311   ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:208712   ACCEPT     tcp      ::/0                 ::/0                state NEW tcp dpt:1000013   REJECT     all      ::/0                 ::/0                reject-with icmp6-adm-prohibited Chain FORWARD (policy ACCEPT)num  target     prot opt source               destination1    REJECT     all      ::/0                 ::/0                reject-with icmp6-adm-prohibited Chain OUTPUT (policy ACCEPT)num  target     prot opt source               destination iptables: Firewall is not running.irqbalance (pid 1826) is running...Kdump is operationallvmetad is stoppedmdmonitor is stoppedmessagebus (pid  1929) is running... SUCCESS! MySQL running (24376)rndc: neither /etc/rndc.conf nor /etc/rndc.key was foundnamed is stoppednetconsole module not loadedUsage: startup.sh { start | stop }Configured devices:lo eth0 eth2Currently active devices:lo eth0ntpd is stoppedportreserve (pid  1749) is running...master (pid  2107) is running...Process accounting is disabled.quota_nld is stoppedrdisc is stoppedrngd is stoppedrpcbind (pid  1840) is running...rsyslogd (pid  1756) is running...sandbox is stoppedsaslauthd is stoppedsmartd is stoppedopenssh-daemon (pid  9859) is running...svnserve is stoppedvsftpd (pid 4008) is running...xinetd (pid  2031) is running...zabbix_agentd (pid 2150 2149 2148 2147 2146 2140) is running...

執(zhí)行以下命令,可以只查看正在運(yùn)行的服務(wù):

# service --status-all | grep running
crond (pid 535) is running...httpd (pid 627) is running...mysqld (pid 911) is running...rndc: neither /etc/rndc.conf nor /etc/rndc.key was foundrsyslogd (pid 449) is running...saslauthd (pid 492) is running...sendmail (pid 509) is running...sm-client (pid 519) is running...openssh-daemon (pid 478) is running...xinetd (pid 485) is running...

運(yùn)行以下命令以查看指定服務(wù)的狀態(tài):

# service --status-all | grep httpdhttpd (pid 627) is running...

或者,使用以下命令也可以查看指定服務(wù)的狀態(tài):

# service httpd statushttpd (pid 627) is running...

使用以下命令查看系統(tǒng)啟動(dòng)時(shí)哪些服務(wù)會(huì)被啟用:

# chkconfig --list
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:offhtcacheclean    0:off   1:off   2:off   3:off   4:off   5:off   6:offhttpd           0:off   1:off   2:off   3:on    4:off   5:off   6:offip6tables       0:off   1:off   2:on    3:off   4:on    5:on    6:offiptables        0:off   1:off   2:on    3:on    4:on    5:on    6:offmodules_dep     0:off   1:off   2:on    3:on    4:on    5:on    6:offmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:offnamed           0:off   1:off   2:off   3:off   4:off   5:off   6:offnetconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:offnetfs           0:off   1:off   2:off   3:off   4:on    5:on    6:offnetwork         0:off   1:off   2:on    3:on    4:on    5:on    6:offnmb             0:off   1:off   2:off   3:off   4:off   5:off   6:offnscd            0:off   1:off   2:off   3:off   4:off   5:off   6:offportreserve     0:off   1:off   2:on    3:off   4:on    5:on    6:offquota_nld       0:off   1:off   2:off   3:off   4:off   5:off   6:offrdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:offrestorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:offrpcbind         0:off   1:off   2:on    3:off   4:on    5:on    6:offrsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:offsaslauthd       0:off   1:off   2:off   3:on    4:off   5:off   6:offsendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:offsmb             0:off   1:off   2:off   3:off   4:off   5:off   6:offsnmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:offsnmptrapd       0:off   1:off   2:off   3:off   4:off   5:off   6:offsshd            0:off   1:off   2:on    3:on    4:on    5:on    6:offudev-post       0:off   1:on    2:on    3:off   4:on    5:on    6:offwinbind         0:off   1:off   2:off   3:off   4:off   5:off   6:offxinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off xinetd based services:        chargen-dgram:  off        chargen-stream: off        daytime-dgram:  off        daytime-stream: off        discard-dgram:  off        discard-stream: off        echo-dgram:     off        echo-stream:    off        finger:         off        ntalk:          off        rsync:          off        talk:           off        tcpmux-server:  off        time-dgram:     off        time-stream:    off

方法二:如何在 System V(SysV)系統(tǒng)中查看運(yùn)行的服務(wù)

另外一種在 Linux 系統(tǒng)上列出運(yùn)行的服務(wù)的方法是使用 initctl 命令:

# initctl listrc stop/waitingtty (/dev/tty3) start/running, process 1740tty (/dev/tty2) start/running, process 1738tty (/dev/tty1) start/running, process 1736tty (/dev/tty6) start/running, process 1746tty (/dev/tty5) start/running, process 1744tty (/dev/tty4) start/running, process 1742plymouth-shutdown stop/waitingcontrol-alt-delete stop/waitingrcS-emergency stop/waitingreadahead-collector stop/waitingkexec-disable stop/waitingquit-plymouth stop/waitingrcS stop/waitingprefdm stop/waitinginit-system-dbus stop/waitingck-log-system-restart stop/waitingreadahead stop/waitingck-log-system-start stop/waitingsplash-manager stop/waitingstart-ttys stop/waitingreadahead-disable-services stop/waitingck-log-system-stop stop/waitingrcS-sulogin stop/waitingserial stop/waiting

方法三:如何在 systemd 系統(tǒng)中查看運(yùn)行的服務(wù)

以下命令幫助我們列出 systemd 系統(tǒng)中所有服務(wù):

# systemctl  UNIT                                                                                     LOAD   ACTIVE SUB       DESCRIPTION                                                        sys-devices-virtual-block-loop0.device                                                   loaded active plugged   /sys/devices/virtual/block/loop0                                   sys-devices-virtual-block-loop1.device                                                   loaded active plugged   /sys/devices/virtual/block/loop1                                   sys-devices-virtual-block-loop2.device                                                   loaded active plugged   /sys/devices/virtual/block/loop2                                   sys-devices-virtual-block-loop3.device                                                   loaded active plugged   /sys/devices/virtual/block/loop3                                   sys-devices-virtual-block-loop4.device                                                   loaded active plugged   /sys/devices/virtual/block/loop4                                   sys-devices-virtual-misc-rfkill.device                                                   loaded active plugged   /sys/devices/virtual/misc/rfkill                                   sys-devices-virtual-tty-ttyprintk.device                                                 loaded active plugged   /sys/devices/virtual/tty/ttyprintk                                 sys-module-fuse.device                                                                   loaded active plugged   /sys/module/fuse                                                   sys-subsystem-net-devices-enp0s3.device                                                  loaded active plugged   82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapter)  -.mount                                                                                  loaded active mounted   Root Mount                                                         dev-hugepages.mount                                                                      loaded active mounted   Huge Pages File System                                             dev-mqueue.mount                                                                         loaded active mounted   POSIX Message Queue File System                                    run-user-1000-gvfs.mount                                                                 loaded active mounted   /run/user/1000/gvfs                                                run-user-1000.mount                                                                      loaded active mounted   /run/user/1000                                                     snap-core-3887.mount                                                                     loaded active mounted   Mount unit for core                                                snap-core-4017.mount                                                                     loaded active mounted   Mount unit for core                                                snap-core-4110.mount                                                                     loaded active mounted   Mount unit for core                                                snap-gping-13.mount                                                                      loaded active mounted   Mount unit for gping                                               snap-termius\x2dapp-8.mount                                                              loaded active mounted   Mount unit for termius-app                                         sys-fs-fuse-connections.mount                                                            loaded active mounted   FUSE Control File System                                           sys-kernel-debug.mount                                                                   loaded active mounted   Debug File System                                                  acpid.path                                                                               loaded active running   ACPI Events Check                                                  cups.path                                                                                loaded active running   CUPS Scheduler                                                     systemd-ask-password-plymouth.path                                                       loaded active waiting   Forward Password Requests to Plymouth Directory Watch              systemd-ask-password-wall.path                                                           loaded active waiting   Forward Password Requests to Wall Directory Watch                  init.scope                                                                               loaded active running   System and Service Manager                                         session-c2.scope                                                                         loaded active running   Session c2 of user magi                                            accounts-daemon.service                                                                  loaded active running   Accounts Service                                                   acpid.service                                                                            loaded active running   ACPI event daemon                                                  anacron.service                                                                          loaded active running   Run anacron jobs                                                   apache2.service                                                                          loaded active running   The Apache HTTP Server                                             apparmor.service                                                                         loaded active exited    AppArmor initialization                                            apport.service                                                                           loaded active exited    LSB: automatic crash report generation                             aptik-battery-monitor.service                                                            loaded active running   LSB: start/stop the aptik battery monitor daemon                   atop.service                                                                             loaded active running   Atop advanced performance monitor                                  atopacct.service                                                                         loaded active running   Atop process accounting daemon                                     avahi-daemon.service                                                                     loaded active running   Avahi mDNS/DNS-SD Stack                                            colord.service                                                                           loaded active running   Manage, Install and Generate Color Profiles                        console-setup.service                                                                    loaded active exited    Set console font and keymap                                        cron.service                                                                             loaded active running   Regular background program processing daemon                       cups-browsed.service                                                                     loaded active running   Make remote CUPS printers available locally                        cups.service                                                                             loaded active running   CUPS Scheduler                                                     dbus.service                                                                             loaded active running   D-Bus System Message Bus                                           postfix.service                                                                          loaded active exited    Postfix Mail Transport Agent
  • UNIT 相應(yīng)的 systemd 單元名稱

  • LOAD 相應(yīng)的單元是否被加載到內(nèi)存中

  • ACTIVE 該單元是否處于活動(dòng)狀態(tài)

  • SUB 該單元是否處于運(yùn)行狀態(tài)(LCTT 譯注:是較于 ACTIVE 更加詳細(xì)的狀態(tài)描述,不同的單元類型有不同的狀態(tài)。)

  • DESCRIPTION 關(guān)于該單元的簡(jiǎn)短描述

以下選項(xiàng)可根據(jù)類型列出單元:

# systemctl list-units --type service  UNIT                               LOAD   ACTIVE SUB     DESCRIPTION                                                        accounts-daemon.service            loaded active running Accounts Service                                                   acpid.service                      loaded active running ACPI event daemon                                                  anacron.service                    loaded active running Run anacron jobs                                                   apache2.service                    loaded active running The Apache HTTP Server                                             apparmor.service                   loaded active exited  AppArmor initialization                                            apport.service                     loaded active exited  LSB: automatic crash report generation                             aptik-battery-monitor.service      loaded active running LSB: start/stop the aptik battery monitor daemon                   atop.service                       loaded active running Atop advanced performance monitor                                  atopacct.service                   loaded active running Atop process accounting daemon                                     avahi-daemon.service               loaded active running Avahi mDNS/DNS-SD Stack                                            colord.service                     loaded active running Manage, Install and Generate Color Profiles                        console-setup.service              loaded active exited  Set console font and keymap                                        cron.service                       loaded active running Regular background program processing daemon                       cups-browsed.service               loaded active running Make remote CUPS printers available locally                        cups.service                       loaded active running CUPS Scheduler                                                     dbus.service                       loaded active running D-Bus System Message Bus                                           fwupd.service                      loaded active running Firmware update daemon                                             getty@tty1.service                 loaded active running Getty on tty1                                                      grub-common.service                loaded active exited  LSB: Record successful boot for GRUB                               irqbalance.service                 loaded active running LSB: daemon to balance interrupts for SMP systems                  keyboard-setup.service             loaded active exited  Set the console keyboard layout                                    kmod-static-nodes.service          loaded active exited  Create list of required static device nodes for the current kernel

以下選項(xiàng)可幫助您根據(jù)狀態(tài)列出單位,輸出與前例類似但更直截了當(dāng):

# systemctl list-unit-files --type service UNIT FILE                                  STATE   accounts-daemon.service                    enabled acpid.service                              disabledalsa-restore.service                       static  alsa-state.service                         static  alsa-utils.service                         masked  anacron-resume.service                     enabled anacron.service                            enabled apache-htcacheclean.service                disabledapache-htcacheclean@.service               disabledapache2.service                            enabled apache2@.service                           disabledapparmor.service                           enabled apport-forward@.service                    static  apport.service                             generatedapt-daily-upgrade.service                  static  apt-daily.service                          static  aptik-battery-monitor.service              generatedatop.service                               enabled atopacct.service                           enabled autovt@.service                            enabled avahi-daemon.service                       enabled bluetooth.service                          enabled

運(yùn)行以下命令以查看指定服務(wù)的狀態(tài):

# systemctl | grep apache2  apache2.service                                                                          loaded active running   The Apache HTTP Server

或者,使用以下命令也可查看指定服務(wù)的狀態(tài):

# systemctl status apache2● apache2.service - The Apache HTTP Server   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)  Drop-In: /lib/systemd/system/apache2.service.d           └─apache2-systemd.conf   Active: active (running) since Tue 2018-03-06 12:34:09 IST; 8min ago  Process: 2786 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS) Main PID: 1171 (apache2)    Tasks: 55 (limit: 4915)   CGroup: /system.slice/apache2.service           ├─1171 /usr/sbin/apache2 -k start           ├─2790 /usr/sbin/apache2 -k start           └─2791 /usr/sbin/apache2 -k start Mar 06 12:34:08 magi-VirtualBox systemd[1]: Starting The Apache HTTP Server...Mar 06 12:34:09 magi-VirtualBox apachectl[1089]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.2.15. Set the 'ServerName' directive globally to suppreMar 06 12:34:09 magi-VirtualBox systemd[1]: Started The Apache HTTP Server.Mar 06 12:39:10 magi-VirtualBox systemd[1]: Reloading The Apache HTTP Server.Mar 06 12:39:10 magi-VirtualBox apachectl[2786]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using fe80::7929:4ed1:279f:4d65. Set the 'ServerName' directive glMar 06 12:39:10 magi-VirtualBox systemd[1]: Reloaded The Apache HTTP Server.

執(zhí)行以下命令,只查看正在運(yùn)行的服務(wù):

# systemctl | grep running  acpid.path                                                                               loaded active running   ACPI Events Check                                                  cups.path                                                                                loaded active running   CUPS Scheduler                                                     init.scope                                                                               loaded active running   System and Service Manager                                         session-c2.scope                                                                         loaded active running   Session c2 of user magi                                            accounts-daemon.service                                                                  loaded active running   Accounts Service                                                   acpid.service                                                                            loaded active running   ACPI event daemon                                                  apache2.service                                                                          loaded active running   The Apache HTTP Server                                             aptik-battery-monitor.service                                                            loaded active running   LSB: start/stop the aptik battery monitor daemon                   atop.service                                                                             loaded active running   Atop advanced performance monitor                                  atopacct.service                                                                         loaded active running   Atop process accounting daemon                                     avahi-daemon.service                                                                     loaded active running   Avahi mDNS/DNS-SD Stack                                            colord.service                                                                           loaded active running   Manage, Install and Generate Color Profiles                        cron.service                                                                             loaded active running   Regular background program processing daemon                       cups-browsed.service                                                                     loaded active running   Make remote CUPS printers available locally                        cups.service                                                                             loaded active running   CUPS Scheduler                                                     dbus.service                                                                             loaded active running   D-Bus System Message Bus                                           fwupd.service                                                                            loaded active running   Firmware update daemon                                             getty@tty1.service                                                                       loaded active running   Getty on tty1                                                      irqbalance.service                                                                       loaded active running   LSB: daemon to balance interrupts for SMP systems                  lightdm.service                                                                          loaded active running   Light Display Manager                                              ModemManager.service                                                                     loaded active running   Modem Manager                                                      NetworkManager.service                                                                   loaded active running   Network Manager                                                    polkit.service                                                                           loaded active running   Authorization Manager

使用以下命令查看系統(tǒng)啟動(dòng)時(shí)會(huì)被啟用的服務(wù)列表:

# systemctl list-unit-files | grep enabledacpid.path                                 enabled cups.path                                  enabled accounts-daemon.service                    enabled anacron-resume.service                     enabled anacron.service                            enabled apache2.service                            enabled apparmor.service                           enabled atop.service                               enabled atopacct.service                           enabled autovt@.service                            enabled avahi-daemon.service                       enabled bluetooth.service                          enabled console-setup.service                      enabled cron.service                               enabled cups-browsed.service                       enabled cups.service                               enabled display-manager.service                    enabled dns-clean.service                          enabled friendly-recovery.service                  enabled getty@.service                             enabled gpu-manager.service                        enabled keyboard-setup.service                     enabled lightdm.service                            enabled ModemManager.service                       enabled network-manager.service                    enabled networking.service                         enabled NetworkManager-dispatcher.service          enabled NetworkManager-wait-online.service         enabled NetworkManager.service                     enabled

systemd-cgtop 按資源使用情況(任務(wù)、CPU、內(nèi)存、輸入和輸出)列出控制組:

# systemd-cgtop Control Group                                              Tasks   %CPU   Memory  Input/s Output/s/                                                              -      -     1.5G        -        -/init.scope                                                    1      -        -        -        -/system.slice                                                153      -        -        -        -/system.slice/ModemManager.service                             3      -        -        -        -/system.slice/NetworkManager.service                           4      -        -        -        -/system.slice/accounts-daemon.service                          3      -        -        -        -/system.slice/acpid.service                                    1      -        -        -        -/system.slice/apache2.service                                 55      -        -        -        -/system.slice/aptik-battery-monitor.service                    1      -        -        -        -/system.slice/atop.service                                     1      -        -        -        -/system.slice/atopacct.service                                 1      -        -        -        -/system.slice/avahi-daemon.service                             2      -        -        -        -/system.slice/colord.service                                   3      -        -        -        -/system.slice/cron.service                                     1      -        -        -        -/system.slice/cups-browsed.service                             3      -        -        -        -/system.slice/cups.service                                     2      -        -        -        -/system.slice/dbus.service                                     6      -        -        -        -/system.slice/fwupd.service                                    5      -        -        -        -/system.slice/irqbalance.service                               1      -        -        -        -/system.slice/lightdm.service                                  7      -        -        -        -/system.slice/polkit.service                                   3      -        -        -        -/system.slice/repowerd.service                                14      -        -        -        -/system.slice/rsyslog.service                                  4      -        -        -        -/system.slice/rtkit-daemon.service                             3      -        -        -        -/system.slice/snapd.service                                    8      -        -        -        -/system.slice/system-getty.slice                               1      -        -        -        -

同時(shí),我們可以使用 pstree 命令(輸出來(lái)自 SysVinit 系統(tǒng))查看正在運(yùn)行的服務(wù):

# pstreeinit-+-crond     |-httpd---2*[httpd]     |-kthreadd/99149---khelper/99149     |-2*[mingetty]     |-mysqld_safe---mysqld---9*[{mysqld}]     |-rsyslogd---3*[{rsyslogd}]     |-saslauthd---saslauthd     |-2*[sendmail]     |-sshd---sshd---bash---pstree     |-udevd     `-xinetd

我們還可以使用 pstree 命令(輸出來(lái)自 systemd 系統(tǒng))查看正在運(yùn)行的服務(wù):

# pstreesystemd─┬─ModemManager─┬─{gdbus}        │              └─{gmain}        ├─NetworkManager─┬─dhclient        │                ├─{gdbus}        │                └─{gmain}        ├─accounts-daemon─┬─{gdbus}        │                 └─{gmain}        ├─acpid        ├─agetty        ├─anacron        ├─apache2───2*[apache2───26*[{apache2}]]        ├─aptd───{gmain}        ├─aptik-battery-m        ├─atop        ├─atopacctd        ├─avahi-daemon───avahi-daemon        ├─colord─┬─{gdbus}        │        └─{gmain}        ├─cron        ├─cups-browsed─┬─{gdbus}        │              └─{gmain}        ├─cupsd        ├─dbus-daemon        ├─fwupd─┬─{GUsbEventThread}        │       ├─{fwupd}        │       ├─{gdbus}        │       └─{gmain}        ├─gnome-keyring-d─┬─{gdbus}        │                 ├─{gmain}        │                 └─{timer}

方法四:如何使用 chkservice 在 systemd 系統(tǒng)中查看正在運(yùn)行的服務(wù)

chkservice 是一個(gè)管理系統(tǒng)單元的終端工具,需要超級(jí)用戶權(quán)限。

# chkservice

怎么查看Linux中所有正在運(yùn)行的服務(wù)

要查看幫助頁(yè)面,請(qǐng)按下 ? ,它將顯示管理 systemd 服務(wù)的可用選項(xiàng)。

怎么查看Linux中所有正在運(yùn)行的服務(wù)

以上是“怎么查看Linux中所有正在運(yùn)行的服務(wù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI