把玩Alpine linux(五): init系统

导读 Alpine Linux使用的是Gentoo同样的OpenRCinit系统.使用"rc-update"、"rc-status"、"rc-service"、"openrc"等命令可用于管理init系统

把玩Alpine linux(五): init系统把玩Alpine linux(五): init系统

rc-updatehtml

rc-update主要用于不一样运行级增长或者删除服务。linux

rc-update语法格式docker

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)

使用实例ssh

$ rc-update add docker boot #增长一个服务
$ rc-update del docker boot #删除一个服务

rc-statuside

rc-status 主要用于运行级的状态管理。ui

rc-status语法格式this

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)

使用实例rest

$ rc-status #检查默认运行级别的状态
$ rc-status -a #检查全部运行级别的状态

rc-servicehtm

rc-service主用于管理服务的状态blog

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 #启动一个服务。
$ rc-service sshd stop #中止一个服务。
$ rc-service sshd restart #重启一个服务。

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 #重启系统,相似于shutdown -r now。
$ halt #关机,相似于shutdown -h now。
$ poweroff #关机

本文原创地址:https://www.linuxprobe.com/alpine-linux-initsystem.html

相关文章
相关标签/搜索