Enable rc.local startup file on Debian 9 (Stretch)

The rc.local script is executed at boot time or when changing runlevels. Adding commands to the bottom of this script is an easy way to perform necessary tasks. However in Debian 9 it is removed by default, but you can add it back with a few steps.

1) Create file rc-local.service in /etc/systemd/system with the following content:

[Unit]
Description=/etc/rc.local
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

2) Create file rc.local in /etc with the following content:

#!/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

3) Add execute permissions to rc.local and enable the script:

chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service

4) Edit rc.local and add your content

Note: you can check the status (or errors) using the command

systemctl status rc-local.service
  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

Set time zone data for CentOS 6

Determine your time zone from /usr/share/zoneinfo. Link /etc/localtime to your time zone.Example:...

Set date and time

From shell, setting date and time is quick and easy:date -s "Thu Jan 5 19:31:30 CST 2017"See also...

The top command displays important system information

Use top to display system uptime, load averages, cpu and memory usage.Enter top and press Shift+m...

Custom Linux Kernels?

FAQ: Can I build a custom kernel on my VPS/VDS?Yes, there is no restriction or special...

Enable SSH root login

On some Linux distributions such as Debian, SSH access for root is disabled by default. If you...