- Find Whether your USB Devices are Connected to Your Linux System using CLI & GUI Tools
- How to List USB Devices in Linux
- Find all connected or plugged in USB drives in Linux through the CLI
- Use the lsusb command to find the number of USB devices plugged in
- Use the mount command to find the number of USB devices plugged in
- Use the lsblk command to find the number of USB devices plugged in
- Use the fdisk command to find the number of USB devices plugged in
- Use the df command to find the number of USB devices plugged in
- Use the dmesg command to find the number of USB devices plugged in
- Find all connected or plugged-in USB drives in Linux through Graphical Way
- Detect number of USB devices plugged in using File Manager
- Use the USBView to find the number of USB devices plugged in
- Use the GParted tool to find the number of USB devices plugged in
- Wrap up
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:
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.
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:
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:
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:
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.
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:
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:
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.
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.
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.