It may be rare to do so, but if one created a file and revoke the permissions, the owner (as well as the group users) can no longer access the file.
midnite@gentoo_bazic /home/midnite % touch file
midnite@gentoo_bazic /home/midnite % chmod 007 file
midnite@gentoo_bazic /home/midnite % ls -l file
-------rwx 1 midnite midnite 0 Apr 13 02:22 file
Owner lost control of his own file.
midnite@gentoo_bazic /home/midnite % cat file
cat: file: Permission denied
midnite@gentoo_bazic /home/midnite % echo 'text' > file
zsh: permission denied: file
Even other users in the same group cannot alter the file neither.
midnite@gentoo_bazic /shared % touch file
midnite@gentoo_bazic /shared % chgrp m_group file
midnite@gentoo_bazic /shared % chmod 007 file
midnite@gentoo_bazic /shared % ls -l file
-------rwx 1 midnite m_group 0 Apr 13 02:41 file
midnite2@gentoo_bazic /shared $ cat file
cat: file: Permission denied
midnite2@gentoo_bazic /shared $ echo 'else' > file
bash: file: Permission denied
gentoo_bazic ~ # cat /etc/group | grep m_group
m_group:x:1002:midnite,midnite2
Of course if the user has write and execute permissions on the directory, he can remove the file (including delete, rename, or moving to another location). This has nothing to do with the file's permission.
However I feel this behaviour quite non-trivial. Many would think the [o]ther permission means every user in the system. It turns out it is everyone BUT the owner nor the group.
Any design rationales behind this property? Any meaningful scenarios where this setting is logical?
chmod 077 file
: now the owner can no longer access it, but other members of the group can. – Nick Matteo Apr 12 '22 at 19:17chmod 0777 file
is a red herring, the file owner can just change the permissions bits back, so it doesn't mean anything. – ilkkachu Apr 12 '22 at 19:19chmod 007
. The point is that it only checks the most specific permission, so if you're the owner, it doesn't matter if you're also in the file's group or not. – Nick Matteo Apr 12 '22 at 19:22chmod 0xx
. – ilkkachu Apr 12 '22 at 19:240xx
permissions mean, like in this question, "don't runchmod 0xx
" is the exact opposite of the advice I'd give! Definitely run it and see what happens. – Nick Matteo Apr 13 '22 at 01:37