Solution: No /etc/rc.local file on Ubuntu 18

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:

sudo su

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):

nano /etc/rc.local

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”.

See also my articles:
Run application at startup in Ubuntu
Using and configuring CRON

Leave a comment

Leave a Reply