21

I run the command: ll /dev/null and got this output:

crw-rw-rw- 1 root root 1, 3 Feb 19 10:20 /dev/null

I know d means directory. Can someone please explain what the c special flag means?

biggz006
  • 351

2 Answers2

25

It's a character device based file Within Linux devices such as hardware are characterised in two ways:

  • Character Devices (c) which are devices which transfer data in characters also known as bytes or bits such as mice, speaker etc.

  • Block Devices (b) which are devices which transfer data in blocks of data such as USB, Hard Disks etc.

These types of files can commonly be found within the /dev directory which is where device files are stored, just type ls -lah and you can see the various types.

If you're running a decent Linux distro, that information (plus more than you could probably ever need) can be obtained with the command:

info ls

which contains this little snippet:


The file type is one of the following characters:
    -  regular file
    b  block special file
    c  character special file
    C  high performance ("contiguous data") file
    d  directory
    D  door (Solaris 2.5 and up)
    l  symbolic link
    M  off-line ("migrated") file (Cray DMF)
    n  network special file (HP-UX)
    p  FIFO (named pipe)
    P  port (Solaris 10 and up)
    s  socket
    ?  some other file type
programmer
  • 1,017
3

It is 'character oriented device' is this case (b means block oriented device)... That's why /dev/null in your example is so efficient in redirections for example with

command 2> /dev/null

In fact it is not a permission but a "definition mark"

francois P
  • 1,219