How To Fix 'chmod: Operation not permitted' (Even As Root)

• Donovan

Why is chmod showing the error: Operation not permitted?

You may be seeing messages like this when trying to change the permissions of a directory or file:

chmod: directory: Operation not permitted

There are basically two main possibilities here:

1. You’re not doing it as root user

Let’s say you just typed as a non-root user:

chmod -R 777 /directory/

If that directory doesn’t belong to your user (i.e. isn’t in /home/user/), then you will get the Operation not permitted error.

To solve this, use sudo or doas when chmod’ing.

doas chmod -R 777 /directory/

2. There are ACL’s at a higher level preventing you from making changes

What’s ACL?

Access Control List.

Think of this as a higher level mechanism for managing file system permissions.

acl may be a default mount option on a filesystem you’re using or you may have it set in fstab.

To see if acl has anything to do with the problem you’re having, type:

getfacl /directory/

This will show permissions.

To change acl permissions, use:

setfacl -m "u:username:rwx" /directory/

To remove acl permissions, use:

setfacl -b /directory/


See the FreeBSD man page to learn more.



Older · View Archive (37)

FreeBSD: What's My IP Address? (How To Find Out)

Newer

FreeBSD: Which Shell Am I Using? (How To Find Out)



Donovan Nagel


Absolute FreeBSD, 3rd Ed.

Absolute FreeBSD

Absolute OpenBSD, 2nd Ed.

Absolute OpenBSD