NetworkManager???? 0:off??? 1:off??? 2:on??? 3:on??? 4:on??? 5:on??? 6:off
abrt-ccpp????????? 0:off??? 1:off??? 2:off??? 3:on??? 4:off??? 5:on??? 6:off
abrtd????????????? 0:off??? 1:off??? 2:off??? 3:on??? 4:off??? 5:on??? 6:off
acpid????????????? 0:off??? 1:off??? 2:on??? 3:on??? 4:on??? 5:on??? 6:off
atd??????????????? 0:off??? 1:off??? 2:off??? 3:on??? 4:on??? 5:on??? 6:off
auditd???????????? 0:off??? 1:off??? 2:on??? 3:on??? 4:on??? 5:on??? 6:off
.
.
如何查看指定服務的狀態
如果你想查看運行級別下某個服務的狀態,你可以使用下面的格式匹配出需要的服務。
比如說我想查看運行級別中 auditd 服務的狀態
# chkconfig --list| grep auditd auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如何在指定運行級別中啟用服務
使用 –level 參數啟用指定運行級別下的某個服務,下面展示如何在運行級別 3 和運行級別 5 下啟用 httpd 服務。
# chkconfig --level 35 httpd on
如何在指定運行級別下禁用服務
同樣使用 –level 參數禁用指定運行級別下的服務,下面展示的是在運行級別 3 和運行級別 5 中禁用 httpd 服務。
# chkconfig --level 35 httpd off
如何將一個新服務添加到啟動列表中
-–add 參數允許我們添加任何新的服務到啟動列表中,默認情況下,新添加的服務會在運行級別 2、3、4、5 下自動開啟。
# chkconfig --add nagios
如何從啟動列表中刪除服務
可以使用 –del 參數從啟動列表中刪除服務,下面展示的是如何從啟動列表中刪除 Nagios 服務。
# chkconfig --del nagios
如何使用 systemctl 命令啟用或禁用開機自啟服務?
systemctl 用于命令行,它是一個用來管理 systemd 的守護進程/服務的基礎工具,例如:(開啟、重啟、關閉、啟用、禁用、重載和狀態)。
所有服務創建的 unit 文件位與 /etc/systemd/system/。
如何列出全部的服務
使用下面的命令列出全部的服務(包括啟用的和禁用的)。
# systemctl list-unit-files --type=service UNIT FILE STATE arp-ethers.service disabled auditd.service enabled autovt@.service enabled blk-availability.service disabled brandbot.service static chrony-dnssrv@.service static chrony-wait.service disabled chronyd.service enabled cloud-config.service enabled cloud-final.service enabled cloud-init-local.service enabled cloud-init.service enabled console-getty.service disabled console-shell.service disabled container-getty@.service static cpupower.service disabled crond.service enabled . . 150 unit files listed.
使用下面的格式通過正則表達式匹配出你想要查看的服務的當前狀態。下面是使用 systemctl 命令查看 httpd 服務的狀態。
# systemctl list-unit-files --type=service | grep httpd httpd.service disabled
如何讓指定的服務開機自啟
使用下面格式的 systemctl 命令啟用一個指定的服務。啟用服務將會創建一個符號鏈接,如下可見:
# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
運行下列命令再次確認服務是否被啟用。
# systemctl is-enabled httpd enabled
如何禁用指定的服務
運行下面的命令禁用服務將會移除你啟用服務時所創建的符號鏈接。
# systemctl disable httpd Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
運行下面的命令再次確認服務是否被禁用。
# systemctl is-enabled httpd disabled
如何查看系統當前的運行級別
使用 systemctl 命令確認你系統當前的運行級別,runlevel 命令仍然可在 systemd 下工作,不過,運行級別對于 systemd 來說是一個歷史遺留的概念。所以我建議你全部使用 systemctl 命令。
我們當前處于運行級別 3, 它等同于下面顯示的 multi-user.target。
# systemctl list-units --type=target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cloud-config.target loaded active active Cloud-config availability cryptsetup.target loaded active active Local Encrypted Volumes getty.target loaded active active Login Prompts local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target loaded active active Network (Pre) network.target loaded active active Network paths.target loaded active active Paths remote-fs.target loaded active active Remote File Systems slices.target loaded active active Slices sockets.target loaded active active Sockets swap.target loaded active active Swap sysinit.target loaded active active System Initialization timers.target loaded active active Timers