I would like to understand in which cases root can be denied access to a file. I am working on a machine I didn't configure (on my personal laptop I obivously don't have this problem) and I am having this problem which can be boiled down to simply this:
touch test.sh &&\ echo 'echo $PATH' >> test.sh &&\ sudo sh test.sh
will give the error:
sh: 0: Can't open test.sh (
bash: test.sh: Permission denied with
I tried to see if I was under SELinux by running
getenforce, but the command was not found.
sudo chown root test.sh, but it gives the error:
chown: cannot access 'test.sh': Permission denied.
Same thing happened when trying to change the ownership of the directory.
I am not necessarily asking for a solution to the overall problem but I want to understand how it's possible that root is denied some access.
On the same machine, if I create a local user (all the above was done as a user logged in via a shared network), all works fine.