rc.local添加开机自启动脚本
通过rc.local添加开机自启动脚本
使用nano编辑器新建rc.local脚本文件,并且添加内容
sudo nano /etc/rc.local
#例如
#!/bin/bash
/sbin/dhclient enp6s18
给予执行权限
sudo chmod +x /etc/rc.local
如果不存在rc-local.service服务,需要手动添加
sudo nano /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
设置rc-local.service开机自启动
sudo systemctl enable rc-local.service
License:
CC BY 4.0