Hello, on video Learning Linux Basics Course & Labs | KodeKloud at 4:03 it says:
“The table here shows some of the commonly used devices along with their major numbers. For a comprehensive list, check out the reference article.”
Where can I find the reference article?
I found on internet this article: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
But it’s unclear what does mean “char” and “block” after device type number.
Some device types (6) have only one char type, some (11) have 2 char types + block, some (18-20) only one block type.
How those char and block devices are distinguished on lsblk output since there is no info about it?
Just my curiosity.
Also, I tried out on my Ubuntu lsblk -a (to list RAMs and other devices), but output didn’t change. Any suggestions?
Thanks in advance.
A Character Device is a device whose driver communicates by sending and receiving single characters (bytes, octets). Example - serial ports, parallel ports, sound cards, keyboard. A Block Device is a device whose driver communicates by sending entire blocks of data. Example - hard disks, USB cameras, Disk-On-Key.
We use the lsblk command to get the block devices only.
To list the character devices use :
sed -n '/^Character/, /^$/ { /^$/ !p }' /proc/devices
Or:
ls -l /sys/dev/char/
You will see the RAM in the char devices list.
Also, you can use this command to list Block devices:
sed -n '/^Block/, /^$/ { /^$/ !p }' /proc/devices
Or:
ls -l /sys/dev/block/
1 Like
Thank you, for the detailed answer.
You’re welcome.
Happy learning!