Linux find connected devices

Find Whether your USB Devices are Connected to Your Linux System using CLI & GUI Tools

Nowadays, we can find many types of USB drives on the market, such as one can easily buy a USB drive the size of a credit card, which you can easily carry in your wallet, or a very micro-sized pendrive that we have lost many times.

Sometimes we connect the thumb drive to our system and because of the missing led light, we are not able to understand whether the device is plugged in, or the USB port is working properly, or the system hasn’t detected the drive like that, there may be a number of questions starting to run through your mind.

And to stop that type of question, you can run some of the utility tools which will confirm the status of the plugged-in USB device on your Linux system.

Therefore, we will introduce some of the Linux commands, which you can leverage to know the USB status from a terminal and subsequently use graphical software too.

How to List USB Devices in Linux

As I said above, I’ll share with you both the method to list out all the connected USB drives on your system. Therefore, we will give you the following options to read this article according to your preference.

If you have not selected any option, then I believe you are very interested in following this guide, so without taking your time much, let me show you the steps.

Find all connected or plugged in USB drives in Linux through the CLI

There are five to six commands that are available to use, through which you are able to understand whether your device is connected to your system successfully or not, and if you do know any other method, then please put that option in the comment section.

Use the lsusb command to find the number of USB devices plugged in

If you are looking for a simple command that is specifically developed for finding information about a drive that is connected to a USB port, then you should use the lsusb command.

In most of the Linux environments, you will find lsusb. If it is not available to your system for any reason, then execute the below command according to your installed distribution.

$ sudo apt install usbutils // Ubuntu or Debian based distributions $ sudo dnf install usbutils // AlmaLinux, Fedora or RHEL based distributions $ sudo pacman -Sy usbutils // Manjaro Linux or Arch based Linux

After that, you run the lsusb command without any option to find out the device that is connected to your system and, of course, attach some external drive to find the drive details.

Читайте также:  Линукс кто ест память

The default behaviour of the above command is attached below:

Check device connected to system using lsusb command

If you want to get more information about a plugged in device, then use -v or –verbose, which will give you more information about the connected drive.

It will work for most cases, no matter what your plugged device is: storage device, keyboard, mouse, or any webcam.

Use the mount command to find the number of USB devices plugged in

If it is a storage device, then most likely your device will get auto-mounted to your system unless and until there is some issue with your drive or port.

So to find the plugged in device information you can use the mount command, which is useful to mount a drive or filesystem to your system.

And if you just run the mount command, then it will print all the mounted file systems along with the mount location and some extra information about partitions or drives.

For the beginner, output may get overwhelmed, but you don’t need to worry because you just need to find the device that has been connected recently. But how do I know which device has been connected recently?

Simple, just look at the bottom of the output where you will find something like /dev/sd##, which means your device is connected to your system and it is known as /dev/sd## along with the path where it is mounted on your system.

For your reference, we have attached the output, so you can get a clear idea.

Check device connected to system using mount command

Instead of that, you can pipe the output of the mount command with grep, which will list the plugged-in device path where it is mounted with some extra information.

$ mount | grep "media"

The behaviour of the above command:

Pipe mount output to grep for better result

Use the lsblk command to find the number of USB devices plugged in

Alternatively, you can use the lsblk command, which will also show the storage device that is connected to your system. To find that information, you just need to run the below command and it will present you with the drive name along with the size of the drive and a few extra details.

The behaviour of the above command:

Check device connected to system using lsblk command

You have to just look at the device name, which will be /dev/sdb if one drive is attached to your system, and the last character gets an increment on the number of drives connected to the system.

Use the fdisk command to find the number of USB devices plugged in

If you do have sudo permission, then you can take advantage of the fdisk command, which can be used for creating partitions, formatting drives, and many more. If you want to learn how to delete a partition from a USB drive, then you must check out this article: How To Delete A Partition In Linux Using the Command Line (fdisk).

When you run the sudo lsblk -l command, it will list out all the partitions that are mounted on your system. To find the same kind of information in your system, execute the below code.

$ sudo fdisk -l

The behaviour of the above command:

Check device connected to system using fdisk command

Now you may be well aware that whenever any drive’s name is other than /dev/sda, then you can consider that drive connected to your system, and of course, you will be able to identify it by looking at the size of the drive.

Use the df command to find the number of USB devices plugged in

Apart from that, you can also use the df command to find the plugged-in drive information.

Читайте также:  Темы значков для linux mint

When you run the df command without any options, you will be able to find out the drive information, but the size of the drive can make you crazy with the weird looking number.

So simply execute the below command, which will print the size of the drive in human-readable format.

The behaviour of the above command:

Check USB device connected to system using df command

Use the dmesg command to find the number of USB devices plugged in

The problem with the above-mentioned command is that it can be beneficial only when you have an attached storage device, except for lsusb. But what about if something else is connected to your system and you want to know whether it has been detected in your system or not?

In this kind of situation, you can check the dmesg (diagnostic message), which is very useful for finding out what is happening under the hood. Anyway, you can run the below command to find USB devices that are detected by the system.

One more thing, if you pipe the dmesg with less command, then it will be easy for you to navigate.

$ dmesg | less

The behaviour of the above command:

DMESG show USB information

Find all connected or plugged-in USB drives in Linux through Graphical Way

From the top section, you have learned how to find the number of USB devices connected to your system using a terminal, and I don’t want you to miss the concept of finding plugged device information using a graphical method.

Detect number of USB devices plugged in using File Manager

The most common and simple way to know whether your external storage devices are connected to your system or not and most systems have a file manager, so you don’t need to download anything.

So, all you have to do is connect the USB drive and open the file manager. On the left side of the file manager window, you will find the plugged-in drive information like in the below image.

Show plugged in device using nautilus file manager

Use the USBView to find the number of USB devices plugged in

If you remember, we used the lsusb command to find the number of devices that are plugged into your system, which was quite good, and I always prefer lsusb over anything else unless I need some more information about the drive.

Interestingly, the same developer who has developed the lsusb command has developed another GTK-based utility to display connected USB drive information using a graphical tool.

Use the GParted tool to find the number of USB devices plugged in

One other interesting tool you can use to check whether your device is connected to your system is GParted, which is an all-in-one tool for managing disks.

If you want to learn more about GParted, then you should check out this Complete Guide to GParted for all Linux Distributions.

First connect your external device to your computer using a USB cable, then open the Gparted disk utility application from your application menu. On the right side of the screen, you will find the drop down menu where all the external device information will be shown, like in the below image.

Check Plugged in device status using GParted

If it is not showing your device name, try to refresh the current window by pressing “Ctrl-R”.

Wrap up

In this article, you have learned several ways through which you can identify whether a USB drive is detected in your system or not. Once again, I will list the command name, which you can use to list the connected external drive information.

If you find something missing in this article, then do let me know.

A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.

Читайте также:  Linux check memory type

Источник

How to List USB Devices in Linux

Nowadays, many computer peripherals such as webcams, mice, scanners, printers, hard drives, USB (Pendrive) now come as USB devices. Once these devices are connected to the Desktop or server it’s important to know the device name or device path. This helps to identify USB devices for the tasks such as formatting.

In Linux, all device files are stored in /dev directory and must be available to the OS during the system boot.

In this guide, we will show you the various ways to list USB devices on Linux. Most commands mentioned here should work on all Linux distributions.

List USB Device Names Using df Command

The df command is a useful command that can help list all mounted volumes, including your USB drives.

Once a USB device is plugged into a Linux system, especially for Desktop, it is automatically mounted in the /media partition and becomes ready for use.

df command check plugged in USB devices

From the output above, I have 1 USB drive /dev/sdb with 2 partitions /dev/sdb1 and /dev/sdb2

List USB Device Name using lsblk Command

Lsblk command is used to list all block devices on a Linux system. From the list, you can filter USB devices using the grep command.

lsblk command check plugged in USB devices

To retrieve additional information such as the UUID, manufacturer and filesystem type, use the blkid command as shown.

blkid command output retrieve information on USB block devices

List USB Device Names Using fdisk Command

You can use the good old fdisk command that is used for partitioning volumes to list all the partitions on the Linux system, including the USB drives.

The command will display detailed information about your USB volume including the partitions, size of the volume, sectors, and the filesystem type.

fdisk command list USB devices

List USB Devices Details using lsusb Command

The lsusb command, also known as the “List USB” command, is used in Linux to list all the USB devices attached to the system.

lsusb command

The output above displays the Bus ID, Device ID, USB ID, and the vendor or manufacturer of the USB devices

The lsusb command simply lists the connected devices and does not provide further information about the usb devices.

For more information about the attached USB devices use the dmesg command. The dmesg command also known as “driver message” or “display the message” is used for examining the boot messages. Additionally, it is used for debugging hardware-related issues and printing messages generated by device drivers.

You can use the dmesg command and grep to narrow down to USB devices.

dmesg command

Also, you can pipe the output of dmesg command to less for easier scrolling.

On the output, you can search for a specific string by pressing the forward slash key ( / ) on your keyboard followed by the name or Device ID of the USB device.

In my case, I’m searching for more information regarding a USB device called SanDisk, which is actually my removable pen drive.

Search for a USB drive

List USB controllers and devices using usb-devices

The usb-devices command is a shell script that allows you to list all the USB controllers and the USB devices connected to your PC. It prints out details of the USB device such as the manufacturer, product name, serial number, and so much more. Here’s the output of the command:

usb-devices command to list usb devices

Conclusion

In this guide, we have demonstrated different ways to list the USB devices attached to the Linux system.

Which is your favorite command to list USB? Please provide your suggestions and feedback in the comment section.

If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks

Источник

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