What does third symbol in "rw-" file mode mean in OS X ls manual page?

11

I have trouble understanding ls's manual regarding a file that has rw- mode. Here's the quote:

  1. If r, the file is readable; if , it is not readable.

  2. If w, the file is writable; if , it is not writable.

  3. The first of the following that applies:

    S     If in the owner permissions, the file is not executable and set-user-ID mode is set.  If in the group permissions, the file is not executable and set-group-ID mode is set.

    s     If in the owner permissions, the file is executable and set-user-ID mode is set.  If in the group permissions, the file is executable and setgroup-ID mode is set.

    x     The file is executable or the directory is searchable.

        The file is neither readable, writable, executable, nor set-user-ID nor set-group-ID mode, nor sticky.

In particular, it seem that two sections in bold contradict each other: according to the first one, since the mode begins with r, the file is readable, but according to the last one, the file is not readable. But, obviously, that is not the case.

So, what does that third section mean about file being "neither readable, writable..."?


Bibliography

  • apple.com seems to be the source of the text quoted above.  This is the man page (for OS X version 10.9, titled "BSD General Commands Manual"), and this is a discussion page that quotes it.
  • ss64.com also has a copy of the OS X ls man page.
  • tuhs.org has the 4.4 BSD man page.  Beware: it uses wwoorrdd for bold and _w_o_r_d for underline.
  • freebsd.org has the FreeBSD 10.1 man page, dated March 15, 2013.
  • unix.com has a copy of the bad page under the man-page/freebsd directory (for FreeBSD 11.0).  Note that they also have a copy of the correct page under man-page/posix.
  • The "A+ 4 Real StudyExam4Less Computer Series" contains the text quoted in the question, plus a couple of paragraphs about T and t, but not the entire man page.  It is talking about OS X.  You can see pages from two slightly different versions (editions?) of this book on books.google.com here and here.   certiguide.com seems to be quoting them.
  • stevens.edu is a PDF file containing the BSD (General Commands Manual) version of ls(1). It is dated September 24, 2011.

Better:

  • quora.com has the same text, but with the formatting (indentation) corrupted so badly that the meaning is ambiguous.

Better yet:

  • cyberciti.biz and hurricanelabs.com have the same text, but with the indentation corrected to the point that one could argue that it's essentially OK.  But they're both still really a mess.

Max Yankov

Posted 2015-06-24T09:03:46.603

Reputation: 213

Moved from here: http://stackoverflow.com/questions/31021900/what-does-third-symbol-in-rw-file-mode-mean

– Max Yankov – 2015-06-24T09:04:02.707

1rwx -- read/write/execute – emirjonb – 2015-06-24T09:23:59.107

@emirjonb I'm not sure how this answers my question. – Max Yankov – 2015-06-24T09:24:38.350

Just a kindly remind, I dont know what are you going to achieve, but if you are just worrying permission problem, you can always chomd 777, which mean you have full control (read/write/execute) to the file/directory. – Bilo – 2015-06-24T09:26:55.647

Please don't post the same question on multiple Stack Exchange sites simultaneously.  ([SU] and [SO] are both Stack Exchange sites.)  As it happens, this question belongs here and not on Stack Overflow. – Scott – 2015-06-24T09:29:00.790

You're not reading the second bold quote properly. That sentence begins with a minus sign (or hyphen), and is explaining what it means. – sawdust – 2015-06-24T09:29:25.150

2@sawdust According to this manual excerpt, a rw- file is simultaneously readable (r), writable (w) and neither readable nor writable (-). – gronostaj – 2015-06-24T09:44:38.647

Where is this "maunal excerpt" from? I cannot find this quoted text in the Linux man pages for ls. – sawdust – 2015-06-24T09:53:25.583

@sawdust it's from OS X. – Max Yankov – 2015-06-24T10:24:29.243

@Bilo: Please do not tell people to do that. Not only is it (potentially) a massive security vulnerability, but it clobbers setuid/setgid/sticky bits, so sudo chmod 777 $(which sudo) will lock you out of the root account on systems that disable root login. – Kevin – 2015-06-24T16:04:06.337

rw- means the file is readable, writable, but not executable. – CML – 2015-06-24T16:15:28.493

>

  • position is for readable: yes/no
  • position is for writable: yes/no
  • position is for executable: yes/no
  • if there is a hyphen (-) it is a no – CML – 2015-06-24T16:16:48.600

    1@CML I don't think that you read the question. – Max Yankov – 2015-06-24T17:05:47.763

    Could you add a link with the source of this man page? ls elsewhere use a different wording. – Braiam – 2015-06-24T20:28:57.897

    @Braiam: I added links to a few copies of the ls man page. – Scott – 2015-06-24T23:32:29.357

    Answers

    16

    This answer was previously posted on Stack Exchange, before I noticed the question was being moved.

    Each numbered point in your quote applies in turn to each of the three characters.

    If the first character is 'r', the file is readable

    If the second character is 'w', the file is writable

    If the third character is 'x/s/S', the file has the executable and/or set-userid/setgroupid property as appropriate

    If the character is '-', then the file does not have that property.

    The first three characters (after the directory identifier) apply to user permissions, the second three to group permissions, and the third to everyone else.

    rojomoke

    Posted 2015-06-24T09:03:46.603

    Reputation: 294

    1OK, this is a good answer to the question, “What does third symbol in rw- file mode mean?”  But the real question is, “How should this OS X ls(1) man page be understood?” and the answer is: “It can’t be; it’s garbled.”  The above post, which quotes and/or paraphrases a correct, coherent ls(1) man page, does not answer the question about the OS X man page. – Scott – 2015-06-24T17:37:02.793

    It is still a great answer; while your answer is technically correct, this one is the most helpful to a random person that would google this man page in the future. – Max Yankov – 2015-06-25T07:11:34.370

    Yes, but the question "What does the output from ls mean?" is much more thoroughly answered at What do the fields in ls -al output mean? on Unix & Linux Stack Exchange.  Also, of course, anybody who Googled such a question would find the millions of good, clear sources on the web, including the non-OS X, non-BSD versions of ls(1)

    – Scott – 2015-06-26T07:14:36.840

    9

    You're right — it doesn't make sense.  It looks like some sort of copy & paste error (although I see that it appears on multiple sites on the web.)

    Scott

    Posted 2015-06-24T09:03:46.603

    Reputation: 17 653

    The (Free)BSD man page has that wording too.

    – user2543253 – 2015-06-24T12:53:25.820

    1this is not a copy & paste error: checkout the answer from rojomoke – CML – 2015-06-24T16:19:36.160

    What’s your point?  rojomoke’s answer presents a coherent explanation of the classic nine-character representation of the mode bits — an explanation that is different from the incoherent one presented in the question.  I believe that it’s quite possible that some tech writer at Apple drastically reformatted something he didn’t really understand, and corrupted the meaning in the process. – Scott – 2015-06-24T17:36:36.050

    The last line would make more sense were it not indented, because the - does represent an absence of a value, but indented the way it is suggests that it's part of the description of item #3, which describes the third symbol of each group. – phyrfox – 2015-06-24T19:21:39.167

    Yes, that's exactly the point of @Max's question — although, if the last line were not indented, then paragraphs 1 and 2 would be redundant, because they also specify conditions under which - appears. – Scott – 2015-06-24T19:41:30.787

    Looks like it goes back as far as 4.4BSD . The 4.3-Reno man page doesn't have this.

    – Mark Plotnick – 2015-06-24T21:31:32.153

    -3

    When changing permissions on a file it is possible to indicate two permissions with a simple rw- or wx- meaning that BOTH r AND w are to be set to NO. In the second example BOTH w AND x are set to NO.

    You could also indicate r+w- to set READ to YES and WRITE to NO. Or rx+ for setting Read AND Execute to YES.

    Roger Baran

    Posted 2015-06-24T09:03:46.603

    Reputation: 8

    1I'm not sure that this is relevant to the question I asked. – Max Yankov – 2015-06-24T12:30:31.430

    1I'm not sure that this is relevant to this planet.     :-)    ⁠ – Scott – 2015-06-24T13:06:59.730

    chmod arguments are not formatted the same way as ls -l outputs. – Peter Cordes – 2015-06-25T06:06:46.133