Teacher
Professional
- Messages
- 2,669
- Reaction score
- 828
- Points
- 113
Not only files and directories are managed in the Linux file system, but also so-called devices. These are specially marked files in which no data is stored, but which rather establish a connection to the Linux kernel.
Devices enable access to many hardware components of the computer, such as hard disks/SSDs, serial and parallel interfaces, the main memory (RAM), etc. Devices are characterized by three pieces of information: the major device number, the minor device number and the type of access (block or character oriented).
The Major Device Number specifies which Linux kernel driver is responsible for management. Most drivers are listed with their Major Device Number on the following page:
For many drivers, the minor device number is used to differentiate between different (related) individual devices - for example, for the driver for hard disks between different partitions
The access type specifies whether the devices are buffered (this is the case for all blockorient devices such as hard disks, etc.) or not (this applies to character-oriented devices such as the serial interface).
If you use ls -l to view the table of contents of /dev, the device numbers (major and minor) are output instead of the file size. The first character of the access bits is b or c (block-oriented or character-oriented)
┌──(teacher㉿carder)-[~]
└─[04:09:54 PM]─$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 May 19 15:09 /dev/sda
Linux-internally there are only so-called inodes in the /dev directory: These are the smallest administrative units of a file system, but no real files with content. New device files can be set up with the command mknod. In practice, however, this is rarely necessary because the udev-system takes care of it automatically. The major and minor device numbers are combined into a 64-bit number.
For security reasons, only root or the members of a certain group may access many devices. To allow other users to access these devices, add the user to this group.
Some device files have a special function: For example, /dev/null serves as a "black hole" to which data can be sent that disappears there forever-for example, to redirect command output that should not be displayed. /dev/zero is an inexhaustible source of 0 bytes, sometimes used to fill files up to a given size with zeros. /dev/random and /dev/urandom supply random numbers.
As a follow up message comes a list of important device files.
Device - Meaning
/dev/cdrom - Link to the CD-ROM device.
/dev/console - the currently active virtual terminal.
/dev/disk/* - additional links to disk and partition devices.
/dev/dri/* - Direct Rendering Infrastructure (3D graphics with X).
/dev/dsp* - Access to the sound card (digital sampling device).
/dev/fb* - Frame Buffer (graphics card).
/dev/input/* - Mouse.
/dev/kmem - Memory (RAM) in core format (for debugger).
/dev/mapper - Mapping files for LVM, crypot container, etc.
/dev/md* - meta devices (RAID etc.).
/dev/mem - memory (RAM).
/dev/mixer* - Access to the sound card.
/dev/port - IO ports.
/dev/pts/* - Virtual terminals according to Unix 98.
/dev/ptyp* - Virtual terminals under X (master).
/dev/ram - RAM disk.
/dev/raw1394 - Direct access to Firewire devices.
/dev/scd* - SCSI/SATA/USB/Firewire CD/DVD drives.
/dev/sd* - SCSI/SATA/USB/Firewire hard disks.
/dev/shm - POSIX shared memory.
/dev/snd - ALSA-sound (link to /proc/
/dev/sr* - SCSI/SATA/USB/Firewire CD/DVD drives.
/dev/tty* - Virtual terminals in text mode.
/dev/ttyp* - Virtual terminals under X (slave).
/dev/ttyS - Serial ports (modern, mouse etc.).
/dev/usb/* - USB devices (see also /proc/bus/usb).
In the past, distributions generated thousands of device files during installation. In fact, at most a few hundred files are used. Only on each computer - depending on the hardware equipment - there are different device files.
The udev system provides a remedy. The background program udevd or systemd-udevd in current distributions recognizes all hardware components connected to the computer and creates the necessary device files as required. udevd or systemd-udevd is started by the init process. The configuration is done by the files of the directory /etc/udev.
In the course of the efforts to start Linux faster, udev was supplemented by the devtmpfs file system. This temporary file system maps the /dev directory. During the boot process, devtmpfs can be used without the overhead of the full udev system.
Devices enable access to many hardware components of the computer, such as hard disks/SSDs, serial and parallel interfaces, the main memory (RAM), etc. Devices are characterized by three pieces of information: the major device number, the minor device number and the type of access (block or character oriented).
The Major Device Number specifies which Linux kernel driver is responsible for management. Most drivers are listed with their Major Device Number on the following page:
For many drivers, the minor device number is used to differentiate between different (related) individual devices - for example, for the driver for hard disks between different partitions
The access type specifies whether the devices are buffered (this is the case for all blockorient devices such as hard disks, etc.) or not (this applies to character-oriented devices such as the serial interface).
If you use ls -l to view the table of contents of /dev, the device numbers (major and minor) are output instead of the file size. The first character of the access bits is b or c (block-oriented or character-oriented)
┌──(teacher㉿carder)-[~]
└─[04:09:54 PM]─$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 May 19 15:09 /dev/sda
Linux-internally there are only so-called inodes in the /dev directory: These are the smallest administrative units of a file system, but no real files with content. New device files can be set up with the command mknod. In practice, however, this is rarely necessary because the udev-system takes care of it automatically. The major and minor device numbers are combined into a 64-bit number.
For security reasons, only root or the members of a certain group may access many devices. To allow other users to access these devices, add the user to this group.
Some device files have a special function: For example, /dev/null serves as a "black hole" to which data can be sent that disappears there forever-for example, to redirect command output that should not be displayed. /dev/zero is an inexhaustible source of 0 bytes, sometimes used to fill files up to a given size with zeros. /dev/random and /dev/urandom supply random numbers.
As a follow up message comes a list of important device files.
Device - Meaning
/dev/cdrom - Link to the CD-ROM device.
/dev/console - the currently active virtual terminal.
/dev/disk/* - additional links to disk and partition devices.
/dev/dri/* - Direct Rendering Infrastructure (3D graphics with X).
/dev/dsp* - Access to the sound card (digital sampling device).
/dev/fb* - Frame Buffer (graphics card).
/dev/input/* - Mouse.
/dev/kmem - Memory (RAM) in core format (for debugger).
/dev/mapper - Mapping files for LVM, crypot container, etc.
/dev/md* - meta devices (RAID etc.).
/dev/mem - memory (RAM).
/dev/mixer* - Access to the sound card.
/dev/port - IO ports.
/dev/pts/* - Virtual terminals according to Unix 98.
/dev/ptyp* - Virtual terminals under X (master).
/dev/ram - RAM disk.
/dev/raw1394 - Direct access to Firewire devices.
/dev/scd* - SCSI/SATA/USB/Firewire CD/DVD drives.
/dev/sd* - SCSI/SATA/USB/Firewire hard disks.
/dev/shm - POSIX shared memory.
/dev/snd - ALSA-sound (link to /proc/
/dev/sr* - SCSI/SATA/USB/Firewire CD/DVD drives.
/dev/tty* - Virtual terminals in text mode.
/dev/ttyp* - Virtual terminals under X (slave).
/dev/ttyS - Serial ports (modern, mouse etc.).
/dev/usb/* - USB devices (see also /proc/bus/usb).
In the past, distributions generated thousands of device files during installation. In fact, at most a few hundred files are used. Only on each computer - depending on the hardware equipment - there are different device files.
The udev system provides a remedy. The background program udevd or systemd-udevd in current distributions recognizes all hardware components connected to the computer and creates the necessary device files as required. udevd or systemd-udevd is started by the init process. The configuration is done by the files of the directory /etc/udev.
In the course of the efforts to start Linux faster, udev was supplemented by the devtmpfs file system. This temporary file system maps the /dev directory. During the boot process, devtmpfs can be used without the overhead of the full udev system.