0

The Linux Command Line Wiillian Shotts

Page 16

Field

-rw-r-—r—-

Meaning

Access rights to the file. The first character indicates the type of file. Among the different types, a leading dash means a regular file, while a d indicates a directory. The next three characters are the access rights for the file's owner, the next three are for members of the file's group, and the final three are for everyone else. Chapter 9 discusses the full meaning of this in more detail.

I didn’t understand this correct, he says the next three characters ,then the next three characters then the final three..

-rw-r—-r—-

I’m only seeing four characters above.. He also says d for directory ,I don’t see any d for directory

Explain please

Kusalananda
  • 333,661

1 Answers1

1

Unix file permissions are divided into three groups of three characters:

user | group | other
-----+-------+------
rwx  | rwx   | rwx

When you see something like:

-rw-r--r--

That means:

user | group | other
-----+-------+------
rw-  | r--   | r--

In other words, the file owner has read + write privileges, members of the file group have read access, and everyone else also has read access.

When the author says, "the next three characters...", he is referring to these groups of three.


The first character represents the "type" of a directory entry, and will be d for directory, as in:

$ ls -ld /usr/bin
dr-xr-xr-x. 1 root root 99276 Sep 13 13:49 /usr/bin/

This first character can also be c for character devices:

$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Sep 14 13:10 /dev/ttyS0

b for block devices (like disks):

$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Sep 14 13:10 /dev/sda

And p for named pipes.

# ls -l /var/lib/nfs/rpc_pipefs/gssd/clntXX/gssd
prw------- 1 root root 0 Sep 14 13:11 /var/lib/nfs/rpc_pipefs/gssd/clntXX/gssd

For regular files, it will be -.

larsks
  • 34,737