2

I am wondering what the type c is in the ls command.

I was following the symlinks at /dev/stdin and ended up with /dev/pts/0

$ ls -l /dev/pts/0
crw--w---- 1 blue tty 136, 0 Apr  8 21:50 /dev/pts/0

I can see the first symbol in the mode output is a c. Now I am trying to find out what this means.

I could find some information but c is not listed and some of them seem also a bit wrong. At least on my box a symlink has a lowercase l, not an uppercase L.

d      if the entry is a directory;
a      if the entry is an append-only file;
D      if the entry is a Unix device;
L      if the entry is a symbolic link;
P      if the entry is a named pipe;
S      if the entry is a socket;
-      if the entry is a plain file.

source: http://manpages.ubuntu.com/manpages/jammy/en/man1/ls.1plan9.html

I can read in man pts that these are pseudo terminal master slave pairs.

ptmx, pts - pseudoterminal master and slave
When a process opens /dev/ptmx, it gets a file descriptor for a pseudoterminal master and a pseudoterminal slave device is created in the /dev/pts directory. Each file descriptor obtained by opening /dev/ptmx is an independent pseudoterminal master with its own associated slave, whose path can be found by passing the file descriptor to ptsname(3).

So what does the c stand for? I assume it means this is a pseudoterminal slave device.

Edit:

After reading and thinking more about it, I guess its c because its essentially a console.

The Fool
  • 165
  • 1
  • 2
  • 8
  • If you are not running Plan9, a Plan9 manual that you've found on the web won't be of much help. Instead, see man ls on your own system. – Kusalananda Apr 08 '22 at 20:20
  • @Kusalananda man ls on my system doesnt say anything about that at all. It has no description of the different types. – The Fool Apr 08 '22 at 20:20
  • 1
    If it's not in the manual, then the manual might have a "SEE ALSO" section. In any case, the answer is elsewhere – Kusalananda Apr 08 '22 at 20:24
  • @Kusalananda, yes thank you. The ALSO section had a link to a webpage and that one had another link where is described https://www.gnu.org/software/coreutils/manual/html_node/What-information-is-listed.html – The Fool Apr 08 '22 at 20:27
  • Ah, so you're on a GNU system. Yeah, they tend to spread their documentation out in various places, for better and for worse. – Kusalananda Apr 08 '22 at 20:30

2 Answers2

3

"c" indicates that the device is a "character special device". If you look in /dev you will also see "b" for "block special device", for instance all of your disks. See Wikipedia.

Device files allow direct access to the device drivers. Historically UNIX would provide bothe a character and block device for block structured devices such as disks. The "c" device allows direct access to the device without going through system buffers. The name is a bit misleading, "raw" would be a better one, but history dictates "c". For a terminal this allows outputting or inputting one or more characters at a time. For a disk though it will not allow a byte level access, the caller must ensure that all block alignment and addressing is done by the caller. "b" devices might be better termed "buffered" devices. The I/O is done to the system's buffers and at a point decided by the system is moved to disk. Due to the buffereing it is possible that the device driver will accept non-aligned blocks of varying size.

2

The first character identifies the file type:

-    Regular file
b    Block special file
c    Character special file
d    Directory
l    Symbolic link
n    Network file
p    FIFO
s    Socket

For a regular file the '-' may be replaced by:

D    Demand recall file
E    Encrypted file
O    Offline file
S    Sparse file