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?
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
c
means it's a character device. Specifically, /dev/tty
represents the current console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With