0

It appears that each file/directory has a given set of permissions shown by the 10 characters to the far left of each listing if one were to type into the terminal ls -l

Considering that you can change the permissions by using chmod OCTAL fileName, it appears to me that such permissions are possibly set by flags of a 10-bit word somewhere in memory?

What I am confused about is that the listing might look something like this: -rw-rw-r--

What exactly does this represent? Why are there several instances of write and read permissions shown by w and r, respectively?

I also read that you must use 6xx (resulting in -rw-------) when writing permissions to files, and 7xx (resulting in drwx------) when writing permissions to directories. Considering that BOTH of these octal representations only expand to 9 bits of information, how are we setting the 10-bit permissions?


I also read that if you want to "remove group and other read permissions" you could use the line:

chmod go-r fileName

First I experimented by doing this: chmod 677 testFile and then used the previously mentioned line: chmod go-r testFile -v and was met with the following output:

mode of testFile changed to 0633 (rw--wx-wx)

I am quite new to this and have yet to find a very succinct and clear write-up on the details.

sherrellbc
  • 839
  • 5
  • 17
  • 31

1 Answers1

2

Owner, group, and everybody else.

There are ten characters there. The first is a "what kind of file is this?" display that we don't need to worry about just yet; the remaining 9 describe the permissions for the file's owner, the file's group, and everybody else.

So if a file's ownership is root:wheel (ie, owner is root and group is wheel), the permissions string -rwxrw-r-- means:

The user root can read, write, and execute The group wheel can read and write Everybody else can just read

(Note that in the context of a directory, "x" means "list contents"; that's why most directories are world-executable.)

And to be complete, in addition to "x", you will sometimes see "s", "t", or "T" in its place, which have to do with group vs. owner permissions and who owns a new file created in a directory. Finally, the first letter will be "d" for directories, and "b" or "c" for device files in /dev.

Bandrami
  • 1,943