rc.local用于预设一些脚本,在系统启动时候调用。而在18.04中默认没有这个文件了。解决办法很简单,先自己新建一个文件:
vim /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. exit 0
然后加上可执行权限:
chmod +x /etc/rc.local
还想Ubuntu 16.04一样,在exit 0前加入需要执行的代码即可。
搞定!
Reference: