有的一些Linux没有/etc/rc.local
文件,该文件主要是用于设置系统开机后的一些自定义初始设置。当缺失时若需要可以自行添加和配置。
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# 在此自行添加想开机启动就执行的脚本或逻辑
然后给/etc/rc.local
添加可执行权限:
chmod 755 /etc/rc.local
可以在rc.local添加开机启动逻辑,
# 启动所有网卡
/lib/ifupdown/ifup_ethernets.sh
参考: 中的DHCP配置方法。
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
systemctl enable rc-local
systemctl daemon-reload
systemctl start rc-local
systemctl status rc-local
因篇幅问题不能全部显示,请点此查看更多更全内容