For compatible reason, rc.local support is still supported by new version of Ubuntu. But it is disabled by default. This will guide you to enable running rc.local while starting system.
- Create rc.local if it does not exist.
nano /etc/rc.local. If the file does not exist, place this code below as the default rc.local file.
#!/bin/bash exit 0
chmod +x /etc/rc.local to give the executing permission.
2. Create systemd service file.
nano /etc/systemd/system/rc-local.service to create the systemd service file and paste this text below.
[Unit] Description=/etc/rc.local Support 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
3. Config systemd using this bash command below.
systemctl enable rc-local
All done. The rc-local will be run while system starting.