1

I have the following file:

------- 1 user user 0 may 26 14:07 a.tar.gz

When I execute chmod 777 a.tar.gz, the file permissions change.

Why does this happen, and how can I block it?

Tlaloc-ES
  • 123
  • 1
  • Permission to change permission is with the owning user. See also https://unix.stackexchange.com/q/101263/4778 – ctrl-alt-delor May 26 '19 at 15:33
  • 1
    It doesn't seem to me the question marked as a duplicate would answer this one. Gilles' answer notes the pieces of data that are stored in the directory vs. in the inode (like the permission bits in question here), but doesn't say anything about the permissions needed to change the latter. – ilkkachu May 26 '19 at 16:10
  • 1
    @ilkkachu "This requires the x permission on the directory (to access the file), and ownership of the file (only the user who owns the file can change its permissions)." (unless I am mistaken) – muru May 27 '19 at 06:01
  • @muru, ooh, it was there, I missed the part in parenthesis... Though yeah, the main point could be more visible, changing the permissions of a file is completely a question of being the owner (or having appropriate privileges), not anything to do with the current permissions or the permissions of the parent directory. (The opposite case of the one in the question: even for a file with permissions 0777 or rwxrwxrwx, if you're not the owner, you can't change the permissions.) – ilkkachu May 27 '19 at 18:55

0 Answers0