Detailed explanation of / dev directory under Linux system


Device is the abbreviation of device/ The directory dev is very important to all users. Because this directory contains all the external devices used in the Linux system. But this is not the driver of the external device, which is different from windows and DOS operating system. It’s actually a port to access these external devices. We can easily access these external devices, and access to a file, a directory is no different.

Linux follows the style of UNIX and regards all devices as one file.

Device files are divided into two types: block device files (b) and character device files (c). Device files are generally stored in the / dev directory

/Dev / HD [A-T]: ide device

/Dev / SD [A-Z]: SCSI device

/Dev / FD [0-7]: standard floppy drive

/Dev / MD [0-31]: soft RAID device

/Dev / loop [0-7]: local loopback device

/Dev / RAM [0-15]: memory

/Dev / null: infinite data receiving device, equivalent to a black hole

/Dev / Zero: unlimited zero resources

/Dev / TTY [0-63]: virtual terminal

/Dev / TTYs [0-3]: serial port

/Dev / LP [0-3]: parallel port

/Dev / console: console


/dev/cdrom => /dev/hdc

/dev/modem => /dev/ttyS[0-9]

/dev/pilot => /dev/ttyS[0-9]

/Dev / random: random number device

/Dev / random: random number device

In Linux system, the / dev directory is used to store device files. Each file points to a system device. The user’s program can use these device files,
For example, HDA is the first IDE hard disk, SDA is the first SCSI hard disk
In the era of 2.4 kernel, there are nearly 10000 device files of all the hardware devices supported by kernel in / dev
It’s a device without connection. It’s a great waste of system resources, and the / dev directory is very confusing
Udev is used to solve these problems. In 2.6 kernel, udev is used to manage / dev directory. It can dynamically create / delete device files (device files)
When connecting to the system, it will automatically create the corresponding device file, and when the device is disconnected, it will automatically delete the corresponding device file)
Moreover, udev also allows users to write naming rules to specify device file names for different devices. In this way, the management of devices is also convenient
For example: you have two USB flash drives, one with 1g capacity and one with 2G capacity. Generally, the USB flash drive you connect first will be SDB, and the USB flash drive you connect later will be SDC
It’s very inconvenient to use. The device name of USB flash disk may be different every time. However, through udev naming rules, you can name the device you specify. You can name a 1g USB flash disk as
1g, 2G U disk named 2G. Device name will not change. Use and management will be very convenient