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.

1

1 Answer 1

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.

6
  • Thank you. What does read/write mean in the context of a directory? Is is referencing the ability to read (create) or write to files within its scope? So if, for example, we have this: drwx000000, only the owner can list the contents of the directory with such permissions?
    – sherrellbc
    Jan 8, 2014 at 3:31
  • 1
    For a directory, "r" lets you read files within it, "w" lets you create files within it, and "x" lets you "traverse" it, i.e., list everything in it. The best one-page description I know is here: linux-tipps.blogspot.in/2008/07/directory-rights-in-linux.html
    – Bandrami
    Jan 8, 2014 at 3:34
  • Right, sorry I mixed it up when I wrote read(create). Thank you for the link.
    – sherrellbc
    Jan 8, 2014 at 3:35
  • 1
    Do read man chmod as it gives you the full documentation on what are the syntaxes and usage.
    – Darius
    Jan 8, 2014 at 3:35
  • 1
    "group and others remove read permissions" chmod can take u, g, and/or o (for user, group, and/or others) a plus or a minus (for add or remove) and w, r, and x (for read/write/execute), along with many other options. I strongly second Darius's suggestion to read the chmod manpage.
    – Bandrami
    Jan 8, 2014 at 3:43

You must log in to answer this question.

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