0

My folder has ownership of mike:adm Its permissions are 770. Note that zero.

My user is mirko and is member only of mirko group

Imagine that root user change ownership of a file inside the folder to mirko:mirko

My user cannot cd into the folder

What can my user do on the file? What not and why?

I suppose I cannot delete file because I cannot 'x' and cannot 'w' the folder

But can I read and write the file content?

1 Answer 1

4

You can not delete a file from a directory where you don't have write permission - assuming a normal unix-like file system..

The important idea is that there are 3 things which are needed for a file

  • The data blocks which hold the actual contents of the file
  • The meta-data which holds the information about the file, such as the owner, the modification date, the permissions, and how to find the data blocks.
  • The name of the file and how to find the meta-data.

Unix allows you to have more than one name for the same file.

A directory is pretty much just a list of pairs of (file name component, pointer to meta-data). When you "delete" a file all you are doing is removing the pair from the directory with the correct final component. When all the names of a file have been removed then the data blocks are available for reuse.

From this it is clear that to "delete" a file you need to be able to alter the directory. This needs write permission to the directory.

Note that to remove a file, or to add an additional name to a file does not require any permissions on the file, this are just operations on directories.

Background

The meta-data is stored in things called i-nodes. The "pointer to meta-data" stored in the directory is actually the index number of an array of i-nodes stored on the disk. Usually these days the array is stored in a series of blocks split across the disk. You can use df -i to see how many entries are in use and the total number available.

1
  • So to delete i need both w and x for directory . Why this do not need also 'r' ?
    – realtebo
    Jun 28, 2022 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .