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
贊(0)
聲明:本網站發布的內容(圖片、視頻和文字)以原創、轉載和分享網絡內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。郵箱:3140448839@qq.com。本站原創內容未經允許不得轉載,或轉載時需注明出處:三五互聯知識庫 » 使用chkconfig和systemctl命令啟用或禁用Linux服務的方法

登錄

找回密碼

注冊

主站蜘蛛池模板: 中文幕无线码中文字夫妻| 18禁无遮挡啪啪无码网站破解版| 秋霞鲁丝片成人无码| 18禁亚洲一区二区三区| 国产免费久久精品44| 色综合人人超人人超级国碰| 国产乱精品一区二区三区| 欧美精品亚洲精品日韩专| 国产女人喷潮视频免费| 蜜臀av一区二区精品字幕| 激情综合色综合啪啪开心| 久久影院综合精品| 亚洲一区二区三区在线| 亚洲人成电影在线天堂色| 韩国午夜理伦三级| 成人国产亚洲精品天堂av| 亚洲性线免费观看视频成熟| 欧美精品亚洲精品日韩专区| 久久人妻精品国产| 中文字幕国产精品二区| 成人性能视频在线| 一日本道伊人久久综合影| 国产三级精品三级在线看| 欧美成人免费一区二区三区视频| 欧美成人精品| 国产超碰无码最新上传| 亚洲大尺度无码无码专线| 色噜噜在线视频免费观看| 十八禁日本一区二区三区| 色护士极品影院| 高清性欧美暴力猛交| 亚洲精品揄拍自拍首页一| 一区二区三区午夜无码视频| 亚洲人成色99999在线观看| 亚洲欧洲一区二区精品| 精品国产成人一区二区| 午夜激情福利一区二区| 午夜国产小视频| av中文字幕国产精品| 国语精品自产拍在线观看网站| 日本视频一区二区三区1|