Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the meaning of 'c' in result of command "ls -l /dev/tty'? [closed]

Tags:

linux

bash

I'm writing some code to interpret the output of the ls command in Linux (to make it more friendly to newcomers). As one of the test cases, I executed the command 'ls -l /dev/tty', and it returned

crw-rw-rw- 1 root root 5, 0 Apr 15 23:46 /dev/tty

What is the meaning of first char 'c' meaning in first column? I know 'd', 'l', and '-'. Could you list all possible values for this field?

like image 467
KyL Avatar asked Apr 23 '14 06:04

KyL


2 Answers

It's a character-based (as opposed to block-based) device file.

Blocked-based devices are anything where it makes sense to transfer data in (surprisingly enough) blocks. By that, I mean things like disks.

Character-based devices (and again, this should come as no surprise) tend to transfer characters at a time. Things like terminals, serial ports, printers and so on.

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
like image 84
paxdiablo Avatar answered Oct 19 '22 10:10

paxdiablo


c means it's a character device. Specifically, /dev/tty represents the current console.

like image 2
Mureinik Avatar answered Oct 19 '22 11:10

Mureinik