Linux 101 : the "/dev" directory - character and block devices -
Linux devices - disks, keyboards, terminals, ... - exist as files in the in the "/dev" directory.
Devices can be refered to using their pathname in the "/dev" directory.
Data could be transferred as characters to character devices - keybord, terminals,... -, it could also be written as blocks to block devices - hard drives -.
To check if a device is a character device or a block device, we use the following:
The two numbers in the middle represent the major number and the minor number of a device.
The major number indicates the driver of the device. We notice that "sda1" and "sda2" have the same major number - they use the same driver -.
The minor number refers to the device. We notice that for the "sda1" it is equal to "1", and for "sda2" it is "2".
In case of a corrupted or missing device, we could use the below command to re-create it using its type and its major and minor numbers. For example to re-create "/dev/sda1", we use:
To check the block and character devices used by our system, we could check the "/proc" virtual filesystem as below: