Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
ls /dev 

command lists the device files.

How to know the associated drivers/major_numbers/minor_numbers with those device files?

share|improve this question
add comment

2 Answers

ls -l /dev will give you the major and minor numbers, e.g.

crw-rw---- 1 root dialout 4, 64 Apr  4 07:54 /dev/ttyS0

has major number 4 and minor number 64.

Then you can look at /proc/devices to look up the major number. In this example we have a character device (c at the start of the line) with major number 4, and in /proc/modules we find

Character devices:
  4 tty
  4 ttyS

Allocation of minor numbers is device-dependent.

Some devices are driven from core kernel code (e.g. tty), whereas others are managed by loadable modules (e.g. rfcomm). You could try looking in /proc/modules for a matching module; alternatively look in /proc/kallsyms for the module name. You'll get lots of results, but the key thing to look for is the presence or absence of a string in square brackets. For example, grep tty /proc/kallsyms gives

0000000000000000 t tty_drivers_open
0000000000000000 t show_tty_range
0000000000000000 t show_tty_driver

whereas grep rfcomm /proc/kallsyms gievs

0000000000000000 t rfcomm_apply_pn  [rfcomm]
0000000000000000 t rfcomm_dlc_debugfs_open  [rfcomm]
0000000000000000 t rfcomm_dlc_debugfs_show  [rfcomm]

[rfcomm] indicates that the code is in the rfcomm module, whereas tty is in the kernel itself and not in a module, so nothing appears in square brackets.

This method is not definitive but should give you some idea as to where the controlling code lives.

share|improve this answer
Thanks. Now for the (char)node, i got its major number, minor number, associated device name. How to find the associated device driver program? –  Karthi prime Apr 4 '13 at 10:12
I've added some detail about drivers to my answer. –  Flup Apr 4 '13 at 10:19
Yes I got some idea. But the information i know are major number, minor number, device name: which is not used in finding the device driver program (modules), using the /proc/modules or /proc/kallsyms right? –  Karthi prime Apr 4 '13 at 10:30
The major number is used to look up the device name in /proc/modules, and the device name is used to look for modules or kernel symbols. –  Flup Apr 4 '13 at 10:36
I got some idea thanks –  Karthi prime Apr 4 '13 at 12:45
add comment

Use the -l option, which displays the numbers.

$ ls -l /dev/sda*
brw-rw---- 1 root disk 8,  0 Jan 22 10:34 /dev/sda
brw-rw---- 1 root disk 8,  1 Dec  4 13:24 /dev/sda1
brw-rw---- 1 root disk 8,  2 Dec  4 13:24 /dev/sda2
brw-rw---- 1 root disk 8,  3 Dec  4 13:24 /dev/sda3

stat displays these as well (as "Device type")

$ stat /dev/sda
  File: '/dev/sda'
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 5h/5d   Inode: 3431        Links: 1     Device type: 8,0
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.