Welcome to the Linux Foundation Forum!

Why can I (as standard user) delete a file with permissions set to 000?

Hello Everybody,

I am currently on Lab 32.2, experimenting with umask values. I have set umask = 0777 and then created a file. This file has zero permissions. I was expecting to need root privileges to remove it but I did not. I am curious as to why. I have attached a screen shot showing the commands from the shell.

Thank you for your thoughts.

Tyler

Distro = Centos 7 minimal install, inside KVM.
user's groups: wheel

Comments

  • You have forgot to paste an important command in your example, which is "ls -ld ."
    You are in your home directory, for which i bet you will have as user "tyler" rwx. What does the "w" mean on a directory? The ability to create and delete files in it.
    This is why you can delete the file. Of course as you can see you get prompted with a warning, "write-protected regular file". This comes from the fact the file itself has no permissions set.

  • coop
    coop Posts: 775

    correct. "write permission" is not the same as "delete" permission. you could not have done something like echo "aline" >> bfile, but you can remove it. Believe me, lots of us have made bad mistakes with this confusion :wink:

  • @KonstantinA @coop
    Thank you! This was simultaneously a "face palm" moment and a "mind blown" moment for me. :smiley:

Categories

Upcoming Training