linux – 什么是像’chkconfig –level 5 iptables on’这样的命令的systemctl等价物
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux – 什么是像’chkconfig –level 5 iptables on’这样的命令的systemctl等价物,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1414字,纯文字阅读大概需要3分钟。
内容图文
![linux – 什么是像’chkconfig –level 5 iptables on’这样的命令的systemctl等价物](/upload/InfoBanner/zyjiaocheng/957/ddc67dc286104876b38045ef2560f873.jpg)
我知道systemctl enable iptables类似于命令chkconfig –level 5 iptables on,但两者并不完全相同.
使用systemctl,我们如何限制仅在给定目标(如graphical.target)上启动服务.
解决方法:
这就是systemd单元文件中的WantedBy =和RequiredBy =指令用于:
从man systemd.unit开始:
WantedBy=, RequiredBy=
This option may be used more than once, or a space-separated list of unit names may be given. A symbolic link is created in the .wants/ or .requires/ directory of each of the listed units when this unit is installed by systemctl enable. This has the effect that a dependency of type Wants= or Requires= is added from the listed unit to the current unit. The primary result is that the current unit will be started when the listed unit is started. See the description of Wants= and Requires= in the [Unit] section for details.
因此,创建的符号链接是导致systemd在目标/单元启动时启动给定单元的原因.
例如:
[Install]
WantedBy=graphical.target
只会在运行graphical.target时启动该单元(如果启用了该单元).
另一个例子:
[Install]
WantedBy=my-custom-target.target graphical.target
当my-custom-target.target或graphical.target运行时(如果启用了该单元),将导致启动该单元.
最后要记住的是,将事物限制在单个目标上可能很困难,因为某些目标依赖于其他目标.例如,graphical.target Requires = multi-user.target,因此当启动graphical.target时,也会启动multi-user.target中的所有单元.请记住,有些目标是建立在其他目标之上的,并且构建在其上的目标将从它们所依赖的目标中获得所有目标.
内容总结
以上是互联网集市为您收集整理的linux – 什么是像’chkconfig –level 5 iptables on’这样的命令的systemctl等价物全部内容,希望文章能够帮你解决linux – 什么是像’chkconfig –level 5 iptables on’这样的命令的systemctl等价物所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。