Find usb linux device

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 computer’s 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.

List All Linux Device Names

Now let’s 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:

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:

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:

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 kernel’s operations.

Читайте также:  Как определить шлюз linux

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

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.

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Delete Huge Files in Linux

Parted Command in Linux

TLDR Man Pages for Linux Commands

apt-get Command Examples

Ubuntu apt-cache Commands

apt Command Examples

18 thoughts on “4 Useful Way to Know Plugged USB Device Name in Linux”

I still have no idea how to make sure by winchester external drive is the right one. I thought I had it and then formatted my main computer drive by mistake. That was a problem. Reply

@Jim You can always identify drives or partitions by their file system type, size as well mount points, however, taking some time to understand naming of storage media under /dev virtual file system will help you avoid such mistakes in the future. Reply

What I need is a name like /dev/somename for a device that is NOT a mass storage device. No luck yet. I did try lsusb, ls /dev/*, df -h, lsblk, sudo fdisk -l. These are all for mass storage devices like memory sticks, camera card readers or external HD Then I tried also usb-devices which lists other devices too, like mouse, printer etc, But it gives some bus number and some device number, no /dev name The reason is that I tried to install the “Samsung unified linux driver” which asks me for the device name of my printer. Unfortunately the names it proposes are crap since they do not exist on my machine ! They propose /dev/mft4 up to /dev/mft11. None of these do exist…
I let it do with /dev/mft4 with a bad presentiment. So finally the installation software affirmed that the driver has been successfully installed and when I click on “testprint” it says that the device can not be found. Of course… Still no solution in sight ! Reply

@Daniel Try to contact the developers of Samsung unified linux driver for any assistance. However, once we find a solution, we will share it with you. Reply

Some of us use external USB-connected drives as system-wide storage. I, for one, would like to mount those file systems elsewhere than /media/. Also, I’d like to use a standard name for some “media” drives instead of a changing label or UUID identifier. For example, the flash storage from my digital camera, I’d like to mount as “…/camera” regardless of the label/UUID. Consider an article that explains how to accomplish that. Reply

Читайте также:  Удаленная поддержка пользователей linux

What about USB devices that are not for data storage? Cameras, humidity sensors, A-D converters, all kinds of tools for monitoring the physical world. Reply

@Joe Very good question, as of now, we can not tell how that can be done, since we have not dealt with the devices you are talking about. However, we will definitely look for more information concerning this question and find relevant ways or command line tools for listing or identifying such(Cameras, humidity sensors, A-D converters, all kinds of tools for monitoring the physical world) USB devices. Thanks for getting in touch. Reply

Источник

How to List USB Devices Connected to Your Linux System

Mostly, people are interested in knowing what USB devices are connected to the system. This may help troubleshoot the USB devices.

The most reliable way is to use this command:

It shows the webcam, Bluetooth, and Ethernet ports along with the USB ports and mounted USB drives.

list usb with lsusb command linux

But understanding the output of lsusb is not easy and you may not need to complicate things when you just want to see and access the mounted USB drives.

I will show you various tools and commands you can use to list USB devices connected to your system.

I have connected a 2GB pen-drive, 1TB external HDD, Android smartphone via MTP and USB mouse in the examples unless stated otherwise.

Let me start with the simplest of the options for desktop users.

Check connected USB devices graphically

Your distribution file manager can be used to view USB storage devices connected to your computer. As you can see in the screenshot of Nautilus (GNOME File Manager) below.

The connected devices are shown in the sidebar (Only USB Storage devices are shown here).

Nautilus showing connected USB devices

You can also use GUI applications like GNOME Disks or Gparted to view, format, and partition the USB Storage devices connected to your computer. GNOME Disks is preinstalled in most distributions using GNOME Desktop Environment by default.

This app also works as a very good partition manager too.

Use GNOME Disks to list mounted USB devices

Enough of the Graphical tools. Let us discuss the commands you can use for listing the USB devices.

Using the mount command to list the mounted USB devices

The mount command is used for mounting partitions in Linux. You can also list USB storage devices using the same command.

Generally, USB storage is mounted in the media directory. Thus, filtering the output of mount command on media will give you the desired result.

Читайте также:  Welcome to my test site!

Using df command

df command is a standard UNIX command used to know the amount of available disk space. You can also use this command to list USB storage devices connected using the command below.

Use df command to list mounted USB drives

Using lsblk command

The lsblk command is used to list block devices in the terminal. So, here also by filtering the output containing media keyword, you can get the desired result as shown in the screenshot below.

Using lsblk to list connected USb devicesUsing blkid to list connected USb devices

If you are more curious, you can use the blkid command to know the UUID, Label, Block size etc.

This command gives more output as your internal drives are also listed. So, you have to take references from the above command to identify the device you wish to know about.

Using blkid to list connected USb devices

Using fdisk

fdisk, the good old command line partition manager, can also list the USB storage devices connected to your computer. The output of this command is also very long. So, usually, the connected devices get listed at the bottom as shown below.

Use fidsk to list usb devices

Inspecting /proc/mounts

By inspecting the /proc/mounts file, you can list the USB Storage devices. As you can notice, it shows you the mount options being used by filesystem along with the mount point.

cat /proc/mounts | grep media

Display all the USB devices with lsusb command

And we revisit the famed lsusb command.

Linux kernel developer Greg Kroah-Hartman developed this handy usbutils utility. This provides us with two commands i.e. lsusb and usb-devices to list USB devices in Linux.

The lsusb command lists all the information about the USB bus in the system.

As you can see this command also shows the Mouse and Smartphone I have connected, unlike other commands (which are capable of listing only USB storage devices).

The second command usb-devices gives more details as compared but fails to list all devices, as shown below.

Greg has also developed a small GTK application called Usbview. This application shows you the list of all the USB devices connected to your computer.

The application is available in the official repositories of most Linux distributions. You can install usbview package using your distribution’s package manager easily.

Once installed, you can launch it from the application menu. You can select any of the listed devices to get details, as shown in the screenshot below.

Conclusion

Most of the methods listed are limited to USB storage devices. There are only two methods which can list other peripherals also; usbview and usbutils. I guess we have one more reason to be grateful to the Linux Kernel developer Greg for developing these handy tools.

I am aware that there are many more ways to list USB devices connected to your system. Your suggestions are welcome.

Источник

Оцените статью
Adblock
detector