Following on from another user's question I've bumped into a quirk of Linux filesystem permissions that I can't easily rationalize:
sudo mkdir ~/foo ~/foo/bar
sudo touch ~/baz
mkdir ~/my_dir
chown 700 ~/my_dir
# this is fine
mv ~/baz ~/my_dir
# renaming is fine
mv ~/foo ~/bob
# Moving caused: Permission denied
mv ~/bob ~/my_dir/
For clarity foo
foo/bar
baz
are owned by root. my_dir
is owned by my own user and of course ~
is owned by my own user. I can rename and move a file owned by another user. I can rename a directory owned by another user, but I can't move a directory owned by another user.
This seems a very specific restriction and I don't understand what danger is being protected against or what underlying mechanism means that it can only work this way.
Why can other users' directories not be moved?
~/foo
and~/foo/bar
, or why~/baz
is a directory. Or how~/baz
got renamed twice, or where~/bob
came from. – ctrl-alt-delor Jun 27 '19 at 13:37baz
is a file. it'sfoo
thenbob
that is a directory. – Philip Couling Jun 27 '19 at 13:42