Ubuntu自动启动配置脚本

Ubuntu自动启动配置脚本

使用下面的脚本保存文件sudo执行一下即可;
手动一步一步操作比较累;

#!/bin/sh -e
cat > /lib/systemd/system/rc.local.service <<EOF
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=no
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service
EOF

cat > /etc/rc.local <<EOF
#!/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.

EOF
chmod +x /etc/rc.local
ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service

systemctl enable rc-local
systemctl status rc-local

参考自: https://blog.csdn.net/idiot_qi/article/details/86527052

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页