cd /lib/systemd/system
进入system目录 找到 rc-local.service 文件
cat rc-local.service
# SPDX-License-Identifier: LGPL-2.1-or-later # # 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 Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no
可以看到ExecStart指向了/etc/rc.local,去到 etc目录找到rc.local,没有则创建(sudo touch rc.local),添加以下内容:
#!/bin/bash sudo dhclient ens33
保存后退出。
sudo systemctl enable rc-local sudo systemctl start rc-local sudo systemctl status rc-local sudo systemctl restart rc-local
标签:systemd,sudo,掉线,ubuntu,网卡,etc,rc,local From: https://www.cnblogs.com/brucewen/p/16771087.html