Enable /etc/rc.local with Systemd

If you are running a Linux distro that uses Systemd, then you may find that your command in /etc/rc.local file would not run at system boot time. This guide explains how to enable /etc/rc.local script to run on system startup.

As root user

  • systemctl status rc-local

if it says – Active: inactive (dead)

then you need to enable

  • systemctl enable rc-local

if you get – The unit files have no installation config

The unit file have no Install section. As such Systemd can not enable it. First we need to create a file:

  • nano /etc/systemd/system/rc-local.service

Add the following

 Description=/etc/rc.local Compatibility

 ExecStart=/etc/rc.local start


To exit the file, Press Ctrl+X.

  • chmod +x /etc/rc.local

Make a rc-local file

  • printf ‘%s\n’ ‘#!/bin/bash’ ‘exit 0’ |  tee -a /etc/rc.local

add execute permission to /etc/rc.local file.

  • chmod +x /etc/rc.local

enable the service on system boot:

  • systemctl enable rc-local

Output should be – Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service -> /etc/systemd/system/rc-local.service.

Start the service and check its status

  • systemctl start rc-local.service
  • systemctl status rc-local.service

The output should be – Active: active (exited) since Fri 2022-07-15 15:57:31 UTC; 7s ago

Now you can – nano /etc/rc.local – edit as needed

Leave a Reply

Your email address will not be published.