溫馨提示×

溫馨提示×

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

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

Alpine Linux如何管理init系統(tǒng)

發(fā)布時間:2022-02-19 10:46:58 來源:億速云 閱讀:197 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹“Alpine Linux如何管理init系統(tǒng)”的相關(guān)知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強,希望這篇“Alpine Linux如何管理init系統(tǒng)”文章能幫助大家解決問題。

Alpine Linux使用的是Gentoo一樣的OpenRCinit系統(tǒng).使用”rc-update”、”rc-status”、”rc-service”、”openrc”等命令可用于管理init系統(tǒng)

Alpine Linux如何管理init系統(tǒng)

rc-update

rc-update主要用于不同運行級增加或者刪除服務(wù)。

rc-update語法格式

Usage: rc-update [options] add [...]
or: rc-update [options] del [...]
or: rc-update [options] [show [...]]

Options: [ asuChqVv ]
-a, --all Process all runlevels
-s, --stack Stack a runlevel instead of a service
-u, --update Force an update of the dependency tree
-h, --help Display this help outputrc-status

-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)

使用實例

$ rc-update add docker boot #增加一個服務(wù)$ rc-update del docker boot #刪除一個服務(wù)

rc-status

rc-status 主要用于運行級的狀態(tài)管理。

rc-status語法格式

Usage: rc-status [options] ...
or: rc-status [options] [-a | -c | -l | -r | -s | -u]

Options: [ aclrsuChqVv ]
-a, --all Show services from all run levels
-c, --crashed Show crashed services
-l, --list Show list of run levels
-r, --runlevel Show the name of the current runlevel
-s, --servicelist Show service list
-u, --unused Show services not assigned to any runlevel
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)

使用實例

$ rc-status #檢查默認運行級別的狀態(tài)$ rc-status -a #檢查所有運行級別的狀態(tài)

rc-service

rc-service主用于管理服務(wù)的狀態(tài)

rc-service語法格式

Usage: rc-service [options] [-i] ...
or: rc-service [options] -e
or: rc-service [options] -l
or: rc-service [options] -r

Options: [ e:ilr:INChqVv ]
-e, --exists tests if the service exists or not
-i, --ifexists if the service exists then run the command-I, --ifinactive if the service is inactive then run the command-N, --ifnotstarted if the service is not started then run the command-l, --list list all available services
-r, --resolve resolve the service name to an init script
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)

使用實例

$ rc-service sshd start #啟動一個服務(wù)。$ rc-service sshd stop #停止一個服務(wù)。$ rc-service sshd restart #重啟一個服務(wù)。

openrc

openrc主要用于管理不同的運行級。

openrc語法格式

Usage: openrc [options] []

Options: [ a:no:s:SChqVv ]
-n, --no-stop do not stop any services
-o, --override override the next runlevel to change into
when leaving single user or boot runlevels
-s, --service runs the service specified with the rest
of the arguments
-S, --sys output the RC system type, if any
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)

Alpine Linux可用的運行級

default
sysinit
boot
single
reboot
shutdown

使用實例

$ openrc single #更改為single運行級

其它指令

$ reboot #重啟系統(tǒng),類似于shutdown -r now。$ halt #關(guān)機,類似于shutdown -h now。$ poweroff #關(guān)機

關(guān)于“Alpine Linux如何管理init系統(tǒng)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點。

向AI問一下細節(jié)

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

AI