I have this directory

drwxrwxrwx 2 root root       4096 May  3 21:06 tmp

I'm the user "jenkins", and I try:

chmod -R a+rwx tmp/

But I get

 chmod: changing permissions of `tmp/': Operation not permitted

why? jenkins also belong to group "wheel"...I don't understand why I can't change permission on the directory

  • 1
    Are you in the root directory as you execute this (so /tmp/ is the same as tmp/)? If so, the answer is: because you aren't the owner of the directory. May 3 '19 at 20:04
  • 2
    Unrelated, but if this is /tmp then the directory is missing the "sticky" bit (there is no t in the permissions). Correct this by doing sudo chmod +t /tmp.
    – Kusalananda
    May 3 '19 at 21:00

In human terms: you're trying to change property which isn't yours: regardless of whether you're jenkins in group wheel or not, you're trying to change the ownership of root in group root so you cannot do that.

You can try sudo make me a sandwich:

sudo chmod --recursive a+rwx /tmp

but you shouldn't!

because everyone already has these rights in /tmp!

(note: /tmp, not tmp/)

  • 3
    You made advanced research on xkcd (+1), delaying the answer! more seriously, considering the tmp/ dir is not +t, I doubt it's /tmp (and hem, it shouldn't have been edited so in OP)
    – A.B
    May 3 '19 at 20:13
  • 1
    @A.B Rolled back to revision 1... 0:-)
    – Fabby
    May 3 '19 at 20:44
  • 1
    Echo... +1 for the xkcd link :)
    – Seamus
    May 4 '19 at 12:34

Only the owner of the directory, root, can change its permissions, allowing or not other users to use this directory (note that root, as the superuser, can anyway change permissions of quite anything, owner or not).

If user jenkins is in the wheel group, this might mean, depending on the exact OS, that user jenkins is allowed to use su or sudo (eg: RHEL) to temporarily become root. So this, perhaps needing jenkins' password, should work:

sudo chmod -R a+rwx tmp/

or else (needing root's password):

su -c 'chmod -R a+rwx tmp/'

Being in the group wheel, if treated in a special way by your OS, doesn't give any direct permission. It grants the right to execute things as root (or other users) using various mechanisms intended for this effect (like su and sudo above), not directly.

  • 1
    Urgh! You beat me! +1
    – Fabby
    May 3 '19 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.