This might be a dumb question, however I was wondering how does Linux keep track of the file permissions? We know if we do a "ls -l" we can see the file permissions but when I change the file permissions where is this information actually modified? File's content doesn't change there must be a another or central location but I cannot find a reference to read. Thanks!
Asked
Active
Viewed 261 times
0
-
3This might be a dumb answer : https://en.wikipedia.org/wiki/Inode ;-) – MC68020 Mar 22 '22 at 21:20
-
So, some bits are flipped in the filesystem for a given file but this information is not transferred to other systems when a file is copied and it makes sense :) – remember5thofnovember Mar 22 '22 at 21:23
-
1This information is not transferred using standard cp. But it can be transferred as well thanks to its -p option. – MC68020 Mar 22 '22 at 21:31
-
I was thinking more of like "scp" to/from other systems. Makes sense. Thanks a lot! – remember5thofnovember Mar 22 '22 at 21:42
-
1One standard method is to tar the files you want to send locally, and pipe that stream to an ssh that embeds a tar extract command. Tar restores the permissions and ownerships (provided the uid is consistent between the two systems). On slow connections you can compress the stream in transit too. – Paul_Pedant Mar 23 '22 at 00:21
-
2Does this answer your question? [What is a Superblock, Inode, Dentry and a File?](https://unix.stackexchange.com/questions/4402/what-is-a-superblock-inode-dentry-and-a-file) – G-Man Says 'Reinstate Monica' Mar 23 '22 at 01:38
-
1"_I was thinking more of like "scp" to/from other systems_" the `scp` command can transfer the metadata too if you ask it to. See `man scp` and use `scp -p ...` – roaima Mar 23 '22 at 10:25
1 Answers
2
That is all part of the data stored in the file system. So, it's stored in the same data structure used to store file names, size and the blocks on the storage device that make up the actual file.
How exactly that memory layout looks – depends on the file system used. But in general permission information about the file is typically stored alongside its basic name/location/extents information.
Marcus Müller
- 21,602
- 2
- 39
- 54