28

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
34

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]

  • 3
    Good though, but it will be better if you expand your answer little more and provide some useful links. :) – Saurav Kumar Dec 30 '13 at 4:06
  • 3
    @SauravKumar please feel free to add some - I couldn't find anything at a suitable level (either added nothing, or dived right into struct char_device C code Kernel programming) – steeldriver Dec 30 '13 at 13:32
  • @steeldriver These might give you a start :) – Seth Dec 30 '13 at 18:59
19

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.

  • is there a way to cat that? – Edik Mkoyan Mar 3 at 15:40
4

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:

1

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.

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.