TranslateProject/sources/tech/20161031 4 Useful Way to Know Plugged USB Device Name in Linux.md
2016-11-15 22:28:59 +08:00

4.6 KiB
Raw Blame History

4 Useful Way to Know Plugged USB Device Name in Linux

As a newbie, one of the many things you should master in Linux is identification of devices attached to your system. It may be your computers hard disk, an external hard drive or removable media such USB drive or SD Memory card.

Using USB drives for file transfer is so common today, and for those (new Linux users) who prefer to use the command line, learning the different ways to identify a USB device name is very important, when you need to format it.

Once you attach a device to your system such as a USB, especially on a desktop, it is automatically mounted to a given directory, normally under /media/username/device-label and you can then access the files in it from that directory. However, this is not the case with a server where you have to manually mount a device and specify its mount point.

Linux identifies devices using special device files stored in /dev directory. Some of the files you will find in this directory include /dev/sda or /dev/hda which represents your first master drive, each partition will be represented by a number such as /dev/sda1 or /dev/hda1 for the first partition and so on.

$ ls /dev/sda* 

List All Linux Device Names

List All Linux Device Names

Now lets find out device names using some different command-line tools as shown:

Find Out Plugged USB Device Name Using df Command

To view each device attached to your system as well as its mount point, you can use the df command(checks Linux disk space utilization) as shown in the image below:

$ df -h

Find USB Device Name Using df Command

Find USB Device Name Using df Command

Use lsblk Command to Find USB Device Name

You can also use the lsblk command (list block devices) which lists all block devices attached to your system like so:

$ lsblk

List Linux Block Devices

List Linux Block Devices

Identify USB Device Name with fdisk Utility

fdisk is a powerful utility which prints out the partition table on all your block devices, a USB drive inclusive, you can run it will root privileges as follows:

$ sudo fdisk -l

List Partition Table of Block Devices

List Partition Table of Block Devices

Determine USB Device Name with dmesg Command

dmesg is an important command that prints or controls the kernel ring buffer, a data structure which stores information about the kernels operations.

Run the command below to view kernel operation messages which will as well print information about your USB device:

$ dmesg

dmesg - Prints USB Device Name

dmesg Prints USB Device Name

That is all for now, in this article, we have covered different approaches of how to find out a USB device name from the command line. You can also share with us any other methods for the same purpose or perhaps offer us your thoughts about the article via the response section below.


via: http://www.tecmint.com/find-usb-device-name-in-linux

作者:Aaron Kili 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出