systemd and rc.local

How to correctly setup rc.local with systemd

I have seen many blogs claiming how to setup rc.local support with system but most of those are talking about setting a new service where as systemd comes with legacy rc.local support.

systemctl status rc-local

Note: you do not have to enable this service, rc-local is automatically executed after network.target using systemd-rc-local-generator.

Create rc.local script

sudo vi /etc/rc.d/rc.local

Add following text

#!/bin/bash
touch /tmp/rc.local.executed

Jjust a touch command, you want to add your commands.

Make rc.l.ocal executable

sudo chmod 700 /etc/rc.d/rc.local

Now reboot and check for /tmp/rc.local.executed

ls -l /tmp/rc.local.executed