The problem here likely has to do with the Access Control List (ACL) of the Music folder. The ACL is a separate permission system to the regular POSIX ones that are normally listed by ls -l
. Some other directories in the Home folder and elsewhere also have ACLs.
Note, I'm referring to the macOS versions of the ls
and chmod
tools to view and modify ACLs below, since this question is tagged osx. Linux systems use getfacl
and setfacl
instead. I'm also using the full paths to the system ls
and chmod
executables, in case you have the Gnu versions installed, e.g. from Homebrew.
To see the ACLs within the home directory, use:
/bin/ls -le ~
You will likely see a rule like 0: group:everyone deny delete
for the Music directory. As you noted you could override the problem with sudo
. If you don't want to do that (or can't), you have other options, given that you're the owner of the file. You can strip off the offending entry from the Music directory's ACL, based on its index (0 in the example I gave above):
/bin/chmod -a# 0 Music
Or you can strip off all entries in the ACL:
/bin/chmod -N Music
Now you can move the directory around (subject to the regular POSIX permissions). If you want to put the ACL back after renaming the directory to Music_tmp, say, you could use:
/bin/chmod +a "group:everyone deny delete" Music_tmp
And use /bin/ls -le
again to verify the ACL.
Check out the ACL examples in man chmod
for more info. In particular, this intro is helpful:
Each file has one ACL, containing an ordered list of entries. Each entry refers to a user or group, and grants or denies a set of permissions. In cases where a user and a group exist with the same name, the user/group name can be prefixed with "user:" or "group:" in order to specify the type of name.
ACL Order
I don't think that man page explains the rules around ordering, but this page explains the order rules for ACLs clearly. In particular, an explicit deny
rule will be applied before an explicit allow
rule. So, as long as the group:everyone deny delete
entry is in place, it's not possible to give your user permission to delete with an allow
rule. This is because permission is denied to the everyone
group, which includes you, and that rule will be applied first.