Home > System Tutorial > LINUX > body text

4 ways to identify USB devices in Linux systems

WBOY
Release: 2024-02-05 11:45:35
forward
1510 people have browsed it

In the desktop environment, when a device (such as a USB device) is inserted, the system will automatically mount it to the specified directory, usually in the /media/username/device-label directory. This way, you can enter the directory and access the files on the device. However, the situation is different on the server. You need to manually mount the device and specify a mount point.

Query USB device

In Linux systems, use specific device files in the /dev directory to identify inserted devices. You will see some files in this directory, such as /dev/sda or /dev/hda, which represent your first primary device, using a number for each partition Identification, such as /dev/sda1 or /dev/hda1 represents the first partition of the main device, and so on. These device files can help you find and identify USB devices connected to your system.

$ ls /dev/sda*
Copy after login
4 种方法识别Linux系统 USB 设备

List all device names under Linux system

Now let's find out the device name using some special command line tools below.

Use the df command to find out the name of the plugged-in USB device

To view each device plugged into your system and the corresponding mount point, you can use the df command in the figure below to check the disk space usage of the Linux system:

$ df -h
Copy after login
4 种方法识别Linux系统 USB 设备

Use the df command to find the USB device name

Use the lsblk command to find the USB device name

You can also use the following lsblk command (list block devices) to list all block devices plugged into your system:

$ lsblk
Copy after login
4 种方法识别Linux系统 USB 设备

List block devices in Linux system

Use fdisk tool to identify USB device name

fdisk is a powerful tool for viewing all partition tables in your system, including all USB devices. Use root privileges to execute the following command:

$ sudo fdisk -l
Copy after login
4 种方法识别Linux系统 USB 设备

List the partition table of the block device

Use the dmesg command to identify the USB device name

dmesg is an important command used to print or control the kernel ring buffer. The ring buffer is a data structure that stores information about the kernel's operating data.

Run the following command to view kernel operation information. It will also print out USB device information:

$ dmesg
Copy after login
4 种方法识别Linux系统 USB 设备

dmesg – Print USB device name

The above is the detailed content of 4 ways to identify USB devices in Linux systems. For more information, please follow other related articles on the PHP Chinese website!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!