36

I'm very familiar with linux file permissions, and special perms (sticky bit, suid, guid)

But I don't know what the c stands for? Is it a permission, or something else? I've done some googling with and can't figure it out.

Here's the device file that has it.

steven@A215:~$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Dec 29 20:58 /dev/null
| improve this question | |
42

It means that the file is a character special file - basically a device file that provides serial access (as opposed to a block special device such as a disk drive). For example terminals and serial devices are interfaced through character special files (/dev/tty1, /dev/ttyS0 and so on).

For a brief introduction to device files, see Linux / UNIX: Device files [cyberciti.biz]. For a more detailed discussion see this stackexchange answer Understanding /dev and its subdirs and files. To learn about the underlying data structures refer to Chapter 4 of The Linux Kernel Module Programming Guide: Character Device Files [tldp.org]

| improve this answer | |
22

A character device is marked with a c as the first letter of the mode string. Likewise, a block device is marked with a b,

$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Jan 21 21:50 /dev/null
$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Jan 21 21:50 /dev/sda

there are more of these special devices (files in a sense that everything is a file in Linux),

d : directory
s : socket
p : pipe
D : Door
l : symbolic link etc.

See this wikipedia page for more details.

| improve this answer | |
5

ls -l outputs a 10 symbol UNIX string of information popularly known as permission string. e.g.

-rw-rw-r--  1 userName groupName   13200650 Dec 13 21:23 fileName

The first character of permission string or mode string, known as the file descriptor, indicates the file type and the remaining nine taken in groups of three indicate the permissions for the file concerned, where:

  • the first group of three characters (after the first character among the 10) indicate owner's permissions,
  • the second group of three designate permissions for the group,
  • the last group of three designate permissions for others (or the world).

Here, in above example the first character/symbol the "-" indicates a normal file.

While in the following examples,

crw-rw-rw- 1 root root 1, 3 Dec 29 20:58 /dev/null
crw-rw-rw- 1 root root 1, 5 Jan 13 20:56 /dev/zero

the permission strings' first character is "c" and like stated above, it is a file-type indicator which indicates a character device.

Apart from the -, c some other file descriptors are:

  • d -> directory
  • l -> symbolic link
  • s -> Unix socket
  • b -> block device
  • p -> pipeline
  • D -> Door

References:

| improve this answer | |
2

The first character in the first column, i.e., 'c ' in crw-rw-rw- above, tells an informed user the type of the file, in this case a character device.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.