Intermediate Linux Flashcards
(149 cards)
Where are device files generally stored?
/dev
Device files are denoted with what characters in the first bit of the ls command?
c - character
b - block
p - pipe
s - socket
Devices are characterized using what two numbers?
major device number and minor device number
How can you interact with device drivers?
Through special files that look like regular files called device files or device nodes
A device takes all of our input and just discards it, so nothing gets returned
/dev/null
What are character devices?
These devices transfer data, but one a character at a time. These are pseudo devices (e.g. /dev/null) that aren’t really physically connected to the machine, but they allow the operating system greater functionality.
What is a block device?
These devices transfer data in large fixed-sized blocks. Most commonly devices such as harddrives, filesystems, etc.
What is a Pipe Device?
They allow two or more processes to communicate with each other, these are similar to character devices, but instead of having output sent to a device, it’s sent to another process.
Similar to pipe devices but they can communicate with many processes at once
Socket device
What does the major device number represent?
The device driver that is used
What does the minor device number represent?
The minor number tells the kernel which unique device it is in this driver class
A protocol used for allow communication between disks, printers, scanners and other peripherals to your system
SCSI (pronounced “scuzzy”) protocol.
SCSI stands for Small Computer System Interface
What does Linux identify with a prefix of sd?
sd (SCSI disk)
Linux systems correspond SCSI disks with hard disk drives in /dev
What is the name of the first and second hard disks in Linux?
First hard disk: /dev/sda
Second hard disk: /dev/sdb
e.g. /dev/sda3 - Third partition on the first hard disk
What are some of the most common pseudo devices?
The most common pseudo devices are character devices:
/dev/zero - accepts and discards all input, produces a continuous stream of NULL (zero value) bytes
/dev/null - accepts and discards all input, produces no output
/dev/random - produces random numbers
Sometimes in older systems you may see hard drives being referred to with what prefix?
hd
/dev/hda - First hard disk
/dev/hdd2 - Second partition on 4th hard disk
What was created to better manage devices on our system than the /dev directory?
A virtual filesystem, Sysfs, most often mounted to the /sys directory
What is the difference between /sys and /dev?
/sys gives us more detailed information than what we would be able to see in the /dev directory
The /dev directory is simple, and it allows other programs to access devices and interact with them
The /sys filesystem is used to view detailed information about the devices, and to manage the devices
$ mknod /dev/sdb1 b 8 3
This is the old way of creating a device node.
This command will make a device node /dev/sdb1 and it will make it a block device (b) with a major number of 8 and a minor number of 3.
How would you remove a device node using old methods?
To remove a device, you would simply rm the device file in the /dev directory
Dynamically creates and removes device files for us depending on whether or not they are connected
The udev system
What does the udevd daemon do?
It’s a daemon that is running on the system and it listens for messages from the kernel about devices connected to the system
What does udevd do when it finds a new device?
Udevd will parse the information and it will match the data with the rules that are specified in /etc/udev/rules.d.
Depending on those rules it will most likely create device nodes and symbolic links for the devices
How can you view the udev database and sysfs?
By using the udevadm command