Debian、Ubuntu系统中开机启动设置

Unix系统使用比较广泛的便是Linux系统,而基于Linux内核下也有很多衍生的其他的系统,其中就有Debian、Ubuntu这类的系统,在Linux系统下平时使用习惯的开机启动/etc/rc.local或/etc/rc.d/rc.local就没有了,那在Debian、Ubuntu下需要开启启动时就需要使用update-rc.d用来定义开机启动的命令 ,举一个简单的例子在Debian、Ubuntu开机启动iptables:

在Debian、Ubuntu中iptables并没有被做成类似Linux下的服务,所以需要启动时就用到update-rc.d,通过man手册得知update-rc.d需要在/etc/init.d目录下有启动文件,所以在Debian、Ubuntu下开启iptables就可以通过以下方式:

root@localhost:/usr/local/scripts#vimiptables.sh
#!/bin/bash
/sbin/iptables-restore</usr/local/scripts/iptables
root@localhost:/usr/local/scripts#ln-sv/usr/local/scripts/iptables.sh/etc/init.d/iptables
root@localhost:/usr/local/scripts#update-rc.diptablesdefaults

这样就在开机启动时就会把自行定义写好的iptables文件导入启用,而在update-rc.d定义一些系统中的服务开机自启也很简单,如开启自启ssh服务:

root@localhost:/usr/local/scripts#update-rc.dsshenable

这样就启用了开机自启ssh服务,类似于Linux系统下的chkconfig、systemctl,当然更多的使用方法可以参看man帮助手册。

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...