Creare e abilitare rc.local in Debian Bullseye

← Torna ad Linux / Debian / Ubuntu

Estratto da https://blog.wijman.net/enable-rc-local-in-debian-bullseye/

Creare il file /etc/rc.local con il seguente contenuto:

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

Dobbiamo ora rendere eseguibile il file con il seguente comando:

chmod +x /etc/rc.local

Quindi dobbiamo ricaricare la configurazione del gestore systemd:

systemctl daemon-reload

Quindi avviamo il demone rc-local:

systemctl start rc-local

Quindi controlliamo lo stato di rc-local per confermare che ha funzionato correttamente:

systemctl status rc-local

Dovresti quindi ottenere un output come quello di seguito che indica che è attivo ed è uscito normalmente:

● rc-local.service - /etc/rc.local Compatibility
     Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/rc-local.service.d
             └─debian.conf
     Active: active (exited)
       Docs: man:systemd-rc-local-generator(8)
    Process: 58756 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)