File permission

It is not a rust problem. I meet it when I use rust to read file. I change a file's permission to None on Linux. But I can read it after that.

If you take away the permission to read the file, then it is not a surprise that you can't read it.

The problem is that I take away the permission but I can still read it.

Aha. In that case it is probably because you are the owner of the file.

I see. I will try it as other user.

What exactly a None permission on Linux? In Linux file permissions are represented by three octal digits - one for the user, one for the group and one for everyone else. If I am not mistaken, by None permission, you mean you have done something like chmod 000 file. But in that case, you cannot read that file at all, even if you own it.

I can read it after I chmod 000 file. That's why I am so confused.

Can you do a ls -l <filename and paste the output?

It's the a.txt

Are you running as root perhaps? The # prompt makes me think so. root has a number of "super-user" capabilities, which include ignoring file permissions.

Take a look at man capabilities, e.g.:

         Bypass file read, write, and execute permission checks.\
         (DAC is an abbreviation of "discretionary access control".)
1 Like

That's because you are root.

1 Like

I see

My advice is "Do not play or experiment when logged in as root"


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.