I have trouble understanding ls
's manual regarding to file that has rw-
mode. Here's the quote:
If r, the file is readable; if -, it is not readable.
If w, the file is writable; if -, it is not writable.
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..."?
Your
ls
man page is not the standard. The POSIX standard man page for ls does not word it in that way. Here is the relevant extract:Which I think makes more sense.
The type is not represented in the permissions bits – you are only looking at what
ls(1)
reports, not how it is stored. Traditionally the mode and type together use 32-bits, but that depends on the file system and on many it is now 64-bits. The permissions are only 9 bits in the inode.See
man 2 stat
and search forst_mode
. It is the low level C routine thatls(1)
probably uses. On some platforms it is also available as a command-line programman 1 stat
.