GTKC Knowledgebase
A little bit of wisdom
Enabling rc.local in Debian 9.x (Stretch)
Posted by  Admin on


Update: 06/05/2020 - I seem to have missed a couple of steps when I created the initial post! (I forgot about the systemd unit file - now corrected)

rc.local has been deprecated in Debian 9.

However, you can still enable it with the following steps.

Create a new file /etc/rc.local

Add the following lines:
#!/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

Make rc.local executable
chmod +x /etc/rc.local


Create a new systemctl unit file
vi /etc/systemd/system/rc-local.service


Add the following to this new file:
[Unit]
 Description=/etc/rc.local Compatibility
 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


Enable rc.local
systemctl enable rc-local


Start the service:
systemctl start rc-local.service

Get the service status:
systemctl status rc-local.service


If successful, the status output should look like this:

systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (running) since Tue 2018-07-31 09:37:33 BST; 3h 49min ago
  Process: 522 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)


Tags: Debian , Linux

Return to home page: Home