/usr/bin/chmod: Permission denied

Linode Staff

I'm receiving the following error when I attempt to change the permissions of a file on my Linode:

/usr/bin/chmod: Permission denied

How can I go about fixing this?

5 Replies

Based on that error, it sounds like you may be running into a permission issue with the chmod binary itself. This introduces a conundrum where you can’t change the permissions of the file that is used to change the permissions of other files! To review the current permissions of this binary file, you can run the following command:

ls -l /usr/bin/chmod

If the permissions for this binary are indeed misconfigured, one way to resolve this issue would be to transfer over a copy of a working chmod binary file from another system.

If that's not an option, however, you can also try copying another binary file from your system (like the binary for the mkdir command), moving the chmod binary’s contents over to the new copy, then renaming the copy to “chmod” to replace the original binary file. For fun, I ran the following commands to do this:

cp /usr/bin/mkdir /usr/bin/chmod.bk
cat /usr/bin/chmod > /usr/bin/chmod.bk
mv /usr/bin/chmod.bk /usr/bin/chmod

If you’re interested, there are some other clever ways to resolve this issue within the following resource:

A more likely explanation is that the OP does not have ownership of file for which he's trying to change permissions. A simple ls -l theFile will confirm this.

/usr/bin/chmod is part of the base Linux system in every distro I'm aware of. It would be an exceedingly bad thing™ for it to be installed with the wrong permissions. Of course, this does not discount the fact that the permissions were changed later in some (unfortunate sudo-newbie) accident.

-- sw

If you're trying to change the permissions of a file that isn't the chmod binary, the error is actually slightly different, at least, on Arch Linux. It's similar to this.

chmod: changing permissions of './testing': Operation not permitted

The permission denied on the chmod executable would, as stated here, provide the permission denied error if executable permissions were unset on the chmod binary.

@tech10 --

You're right… However trying to chmod of /usr/bin/chmod yields the same message as trying to chmod any other file you don't own:

[email protected]:/boot$ chmod a+w /boot/vmlinuz-4.19.0-14-amd64
chmod: changing permissions of '/boot/vmlinuz-4.19.0-14-amd64': Operation not permitted

[email protected]:~$ chmod a-w /usr/bin/chmod
chmod: changing permissions of '/usr/bin/chmod': Operation not permitted

This is Debian 10. Methinks the OP is not using /usr/bin/chmod to do what s/he queried about… Perhaps an alias or a shell-script wrapper?

-- sw

Reproducing the error as root, it is possible. DO NOT do this unless you know what you are doing.

# cp -a /usr/bin/chmod /usr/bin/chmod-bak
# chmod 644 /usr/bin/chmod
# chmod +x ./backup.sh
-bash: /usr/bin/chmod: Permission denied
# mv /usr/bin/chmod-bak /usr/bin/chmod
# chmod +x ./backup.sh


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct