温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Alpine Linux如何管理init系统

发布时间:2022-02-19 10:46:58 来源:亿速云 阅读:178 作者:iii 栏目:开发技术

这篇文章主要介绍“Alpine Linux如何管理init系统”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Alpine Linux如何管理init系统”文章能帮助大家解决问题。

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

Alpine Linux如何管理init系统

rc-update

rc-update主要用于不同运行级增加或者删除服务。

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 #增加一个服务$ rc-update del docker boot #删除一个服务

rc-status

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

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 #检查默认运行级别的状态$ rc-status -a #检查所有运行级别的状态

rc-service

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

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 #关机

关于“Alpine Linux如何管理init系统”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI