I once noticed that by default there is no /etc/rc.local file in Ubuntu 18, but it can be created.
To do this, switch to the root user:
Create a file /etc/rc.local for example with the nano editor (Ctrl+X to exit the editor, y/n to save or cancel changes):
Add content to it like in Ubuntu 16:
#!/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
Let’s make the file executable:
chmod +x /etc/rc.local
Done, now you can write your own commands and they will be executed when the operating system starts, the last line must remain “exit 0”.