I am a bit of a noob and I have been following this tutorial to setup rc.local on ubuntu 20.04 as I want to change ownership of folder on boot.
The script is saved in chownscript.sh and it is:
#!/bin/bash
chown -R 1001:1001 /opt/redis
exit 0
When I run it as sudo ./chownscript.sh
it works fine.
My rc.local file is
#!/bin/sh -e
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Ensure that the script will "exit 0" on success or any other
# value on error.
#
# To enable or disable this script, just change the execution
# bits.
#
# By default, this script does nothing.
sh /opt/chownscript.sh
exit 0
My /etc/systemd/system/rc-local.service file is
[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.targ[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
when i run systemctl status rc-local.service
i get
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Wed 2023-03-29 19:55:53 UTC; 16min ago
Process: 651 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
CPU: 24ms
Mar 29 19:55:53 ubuntu-server-2 systemd[1]: Starting /etc/rc.local Compatibility...
Mar 29 19:55:53 ubuntu-server-2 sudo[653]: root : PWD=/ ; USER=root ; COMMAND=/usr/bin/chown -R 1001:1001 /opt/redis
Mar 29 19:55:53 ubuntu-server-2 sudo[653]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Mar 29 19:55:53 ubuntu-server-2 sudo[653]: pam_unix(sudo:session): session closed for user root
Mar 29 19:55:53 ubuntu-server-2 systemd[1]: Started /etc/rc.local Compatibility.
However when I check folder permisions nothing has changed. Any suggestions on what I am doing wrong?