L in u X ba sics for h acke rs g e t t I n g s t a r t e d w I t h


Download 7.3 Mb.
Pdf ko'rish
bet103/115
Sana27.10.2023
Hajmi7.3 Mb.
#1728481
1   ...   99   100   101   102   103   104   105   106   ...   115
Bog'liq
linuxbasicsforhackers

Character and Block Devices
Something else to note about the naming of device files in the /dev direc-
tory is that the first position contains either c or b. You can see this in List-
ing 10-1 at the start of most of the entries, and it looks something like this:
crw------- 1 root root 10, 175 May 16 12:44 agpgart
These letters represent the two ways that devices transfer data in and 
out. The c stands for character, and these devices are known, as you might 
expect, as character devices. External devices that interact with the system 
by sending and receiving data character by character, such as mice or key-
boards, are character devices.
The b stands for the second type: block devices. They communicate in 
blocks of data (multiple bytes at a time) and include devices like hard drives 
and DVD drives. These devices require higher-speed data throughput and 
therefore send and receive data in blocks (many characters or bytes at a 
time). Once you know whether a device is a character or block device, you 
can easily get more information about it, as you’ll see next.
List Block Devices and Information with lsblk
The Linux command 
lsblk
, short for list block, lists some basic information 
about each block device listed in /dev. The result is similar to the output 
from 
fdisk -l
, but it will also display devices with multiple partitions in a 
kind of tree, showing each device with its partitions as branches, and does 
not require root privileges to run. In Listing 10-3, for example, we see sda, 
with its branches sda1, sda2, and sda5.
kali >lsblk
Name MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda1 8:0 0 20G 0 disk
|-sda1 8:1 0 18.7G 0 part /
|-sda2 8:2 0 1K 0 part
|-sda5 8:5 0 1.3G 0 part [SWAP]


106
Chapter 10
sdb 8:16 1 29.8G 0 disk
|-sdb1 8.17 1 29.8G 0 disk /media
sr0 11:0 1 2.7G 0 rom
Listing 10-3: Listing block device information with lsblk
The output may include the floppy drive as fd0 and DVD drive as sr0, 
even though neither is on my system—this is simply a holdover from legacy 
systems. We can also see information on the mount point of the drive—this is 
the position at which the drive was attached to the filesystem. Note that the 
hard drive sda1 is mounted at / and the flash drive is mounted at /media
You’ll see more on the significance of this in the next section.

Download 7.3 Mb.

Do'stlaringiz bilan baham:
1   ...   99   100   101   102   103   104   105   106   ...   115




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling