0

I am currently writing a file managing system in python, now I want to know how can I change the rights for access to a file or folder in a most basic way. I'm programming on a RPi3.

I am familiar with linux and python, but I want a "solution closer to the basis of linux". I know well that I could do it by running a shell command with subprocess or so. I want some deep experience with file rights and such stuff.

I still have problems with the real basic understanding of the rwx-stuff. Are there a couple of bits that are set to the corresponding values in the actual file or are the right saved somwhere on the drive inbetween the files in a folder? Are the informations stored in the folder containing the file? I really can't imagine how to access this information and/or change it.

My final questions are:

  • How does the right system work in the deepest level?

  • Is there some part in the os-libary or some other library to manage this task?

I special I'd appreciate a solution for RPi3 but any solutio for linux would be handy as well.

Thanks in advance!

monamona
  • 1,195
  • 2
  • 17
  • 43
  • 1
    You want `os.chmod`. It's the Python version of the `chmod` shell command. – kindall Nov 22 '17 at 19:23
  • I guess thats a quite basic way to do this. I definitely will consider doing that! Do you know something about the information of the `rwx`rights and heir location? – monamona Nov 22 '17 at 19:25
  • 2
    They're part of the file's metadata and stored in the directory along with the file's name, creation/modification date/time, etc. There is a lot of literature on UNIX file permissions since they've been around for 40+ years. [Wikpedia has an intro](https://en.wikipedia.org/wiki/File_system_permissions#Traditional_Unix_permissions). – kindall Nov 22 '17 at 19:30
  • The proposed duplicate tells you about how to do this in Python. The basic semantics of the Unix permission system isn't really a programming topic. Try e.g. https://en.wikipedia.org/wiki/File_system_permissions – tripleee Nov 23 '17 at 08:55

0 Answers0