Page 1 of 1

ls question (I'm so embarassed..)

Posted: Sun Jan 14, 2018 12:24 am
by spikemc1968
Hi, I'm writing a script that uses the output from the "ls -l" command, and I'm seeing a column between the group and size fields that looks very useful, but I have no idea what it is! Can anyone tell me what the "250," field is in the output below? I checked the man page for ls and searched for a couple hours but I can't figure it out...

crw------- 1 root root 250, 0 Jan 12 13:24 vc-mem

Thank you!

Re: ls question (I'm so embarassed..)

Posted: Sun Jan 14, 2018 2:09 am
by rpdom
In that particular instance you are looking at a device file, not a normal file. Device files are identified by a Major and Minor device number. The first number 250 is the major number, the second number 0 is the minor number.

One example of this is your SD card, where on a standard (non-NOOBS) Raspbian install you will see something like the following

Code: Select all

pi@raspi9:~ $ ls -l /dev/mmcblk*
brw-rw---- 1 root disk 179, 0 Mar 29  2017 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Mar 29  2017 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Mar 29  2017 /dev/mmcblk0p2
In this case, the Major number that identifies the card device is 179. Minor number 0 is the whole raw card. Minor number 1 is the first partition, Minor number 2 is the second partition.

Re: ls question (I'm so embarassed..)

Posted: Sun Jan 14, 2018 2:19 am
by spikemc1968
Thank you so much! It's all so clear now... I was in the /dev directory. Now I understand why some files had a "size" of zero (I was mistaking the minor device number for the file size).

Thanks again!