8 Effective Methods to List USB Devices Linux

Written by

Reviewed by

Last updated: May 20, 2024

Expert verified

SVG Image

TL;DR

To list USB devices Linux, you can try these methods:

  1. Use the lsusb command to list connected USB devices, showing vendor and product IDs, and device names.
  2. Use udevadm monitor --udev --subsystem-match=usb to monitor and get detailed information on USB device events.
  3. Access /sys/bus/usb/devices to get detailed information about USB devices, including vendor and product IDs, and device classes.

Continue reading the guide below to learn different methods to list USB devices Linux and best practices for managing USB devices.

Struggling to see which USB devices are connected to your Linux system? Whether you’re troubleshooting a problem or just keeping track of your hardware, there’s a solution. This post will guide you through several methods to list USB devices in Linux. You’ll learn how to use commands like lsusb, dmesg, lsblk, and more to get detailed information about your USB devices. By the end of this guide, you’ll have a clear understanding of how to manage and monitor your USB devices effectively. Let’s explore!

How to List USB Devices Linux?

To check USB devices Linux, you can use several commands that provide detailed information about the connected devices. Start by using the lsusb command, which gives a straightforward list of all USB devices. For more detailed information, use the dmesg | grep -i usb command to see kernel messages related to USB events. Additionally, you can use lsblk to view block devices and identify USB drives, and blkid to see device attributes.

That was the quick answer. Here is the detailed step-by-step guide to Linux check USB devices:

1. lsusb Command

The lsusb command is a powerful utility that allows you to list USB devices connected to your Linux system. With a simple command, you can quickly retrieve essential information such as vendor and product IDs, device names, and more. Follow these simple steps to Ubuntu list USB devices:

  1. Open a Terminal window.
opening terminal 6
  1. Execute the following command: 
lsusb

A list of connected USB devices will be displayed, including information such as vendor and product IDs, device names, and more.

    listing usb devices using ls command 1

    2. udev System

    The udev system plays a crucial role in device management on Linux. By utilizing the udevadm command, you can monitor USB device events in real time and receive detailed information about connected or disconnected USB devices. Here’s how you can use this method to Linux show USB devices:

    1. Access the terminal on your Linux system and run the command: 
    udevadm monitor --udev --subsystem-match=usb
    1. You will receive output that includes detailed information about the connected or disconnected USB devices.
    viewing connected and disconnected usb devices

    3. /sys Filesystem

    The /sys filesystem provides a wealth of information about various system resources, including USB devices. This method provides a quick and convenient way to retrieve specific details such as vendor and product IDs, device classes, and more. Follow these steps to access USB device information:

    1. Launch your command window and enter the following command:
    ls /sys/bus/usb/devices
    1. A detailed output containing information about connected USB devices, such as vendor and product IDs, device classes, and more, will be displayed.
    viewing detailed info about connected usb devices

    4. System Monitoring Tools (htop) 

    System monitoring tools offer a convenient way to identify USB devices on your Linux system. This section lists the connected USB devices along with additional information such as power usage and device status, allowing you to keep track of USB device performance effortlessly. Here’s how you can use this method to show USB devices Linux:

    1. Install a system monitoring tool such as htop by running the command: 
    sudo apt-get install htop
    1. The command will install htop on your system.
    installing htop on ubuntu
    1. Launch the system monitoring tool from the application menu.
    launching htop from application menu
    1. The connected USB devices will be listed, along with additional information such as power usage and device status.
    viewing usb devices info uisng htop system monitor

    5. dmesg Command

    The dmesg command displays the system’s kernel messages, which include detailed logs about hardware events such as USB device activity. This command helps you understand how the kernel interacts with USB devices, providing insights into any issues that may arise.

    1. In your Terminal window use the following command to filter and display only USB-related messages:
    sudo dmesg | grep -i usb

    A filtered dmesg output might look like this:

    viewing usb related messages using dmesg
    • Timestamp: The time (in seconds) since the system started.
    • usb 1-1: The USB bus and port number.
    • new high-speed USB device: Indicates a new device connection.
    • idVendor and idProduct: Vendor and product identifiers.
    • Product, Manufacturer, SerialNumber: Descriptive strings for the device.

    These messages provide detailed information about the USB device, including when it was connected and its attributes.

    6. lsblk Command

    The lsblk command is used to list information about all available or specified block devices in a tree-like format. This command is useful for identifying USB storage devices and viewing their partitions and other attributes.

    1. Launch your terminal application to enter commands.
    2. Use the following command to list block devices and their attributes:
    lsblk -o NAME,FSTYPE,LABEL,SIZE

    The output might look like this:

    viewing block devices using lsblk
    • NAME: Device name.
    • FSTYPE: Filesystem type.
    • LABEL: Volume label.
    • SIZE: Size of the device or partition.

    In this example, sdb is the USB device, identifiable by its size and label.

    identifying usb device

    7. fdisk Command

    The fdisk command is a powerful tool for managing disk partitions. It provides detailed information about each partition on a device, making it useful for identifying and managing USB storage devices.

    1. Launch your terminal application and run the following command to list all disk partitions, including those on USB devices:
    sudo fdisk -l

    The output will be:

    listing all disks partitions using fdisk
    • Disk: Device name and size.
    • Device: Partition name.
    • Start/End: Start and end sectors.
    • Blocks: Size of the partition.
    • Id: Partition type identifier.
    • System: Filesystem type.

    In this example, /dev/sdb is the USB device, and /dev/sdb1 is its partition.

    viewing usb and its partitions

    8. blkid Command

    The blkid command is used to locate and print block device attributes. It provides quick access to information about filesystems, labels, and UUIDs, which can help identify USB devices.

    1. Access your command window and use the following command to list block devices and their attributes:
    sudo blkid

    You will see following output:

    viewing block devices using blkid
    • /dev/sda1: Device name.
    • UUID: Unique identifier for the filesystem.
    • TYPE: Filesystem type.
    • LABEL: Volume label.

    In this example, /dev/sdb1 is the USB device, identifiable by its label “USB” and filesystem type “vfat”.

    Best Practices for Managing USB Devices in Linux

    Proper management of USB devices in Linux ensures they function well and data remains secure. Here are five best practices to help you manage your USB devices effectively, ensuring reliability and longevity for both your system and peripherals.

    • 💻 Regularly Monitor Devices: Use commands like lsusb, lsblk, and dmesg to regularly check the status of your USB devices. This helps identify issues early and ensures all devices are functioning correctly. Regular monitoring can also help you detect unauthorized devices or hardware failures promptly.
    • 🔄 Safely Remove Devices: Always unmount USB devices before physically removing them. Use commands like umount /dev/sdX or GUI options to prevent data corruption and ensure safe removal. Proper unmounting ensures that all data is written to the device and helps maintain the integrity of your files.
    • 📅 Keep System Updated: Regularly update your Linux system and kernel to ensure compatibility with new USB devices and improved performance. Use package managers like apt, yum, or dnf to keep your system current. Updates often include important bug fixes and security patches that protect against vulnerabilities.
    • 🛡️ Set Proper Permissions: Ensure USB devices have the correct permissions to avoid unauthorized access. Use chmod and chown commands to manage file and device permissions, enhancing security. Proper permissions help prevent data breaches and ensure that only authorized users can access sensitive information on your USB devices.
    • ⚙️ Monitor Power Usage: Monitor the power consumption of USB devices to avoid overloading your system. Use tools like powertop to check and optimize power usage, ensuring stable and efficient operation. Efficient power management can extend the lifespan of your hardware and improve overall system performance.

    Linux List USB Devices: Wrapping Up

    In this article, I’ve covered how to Linux check connected USB devices and shared best practices for managing them. These include regular monitoring, safe removal, keeping the system updated, setting proper permissions, and monitoring power usage.

    For further learning, consider exploring these related topics:

      Frequently Asked Questions

      How can I identify USB devices that are not recognized or listed?

      If a USB device is not recognized or listed, you can try the following steps: First, check if the device is properly connected and powered. Ensure that the USB cable is securely plugged into both the device and the computer. If that doesn’t work, try using different USB ports or cables to rule out any hardware issues. Sometimes, a specific port or cable may be faulty. Restart your system and check if the device is detected upon reboot. If the issue persists, consult the official documentation or support forums for your specific Linux distribution for troubleshooting steps tailored to your system.

      Is it possible to automate USB device listing in Linux?

      Yes, it is possible to automate USB device listing in Linux by utilizing scripting languages like Bash or Python. With custom scripts, you can automate the process of listing and monitoring USB devices, saving you time and effort. By writing scripts that leverage the available methods, such as using commands like lsusb or parsing system files like /proc/bus/usb/devices, you can create automated routines to list and gather specific information about connected USB devices.

      Can I retrieve specific details about USB devices using these methods?

      Absolutely! Each of the listed methods provides varying levels of detail about USB devices. When using commands like lsusb, you can retrieve information such as vendor and product IDs, device names, classes, power usage, and more. Similarly, exploring the /proc filesystem or utilizing system monitoring tools like htop can provide additional details about the USB devices, including configuration settings and connection information.

      Listing USB devices in Linux does not pose any direct security risks. However, it’s important to exercise caution when connecting USB devices from untrusted sources. USB devices can carry security threats such as malware or be used as a vector for data breaches. To mitigate these risks, it is advisable only to use reliable and trusted USB devices from reputable manufacturers. Additionally, keep your Linux system up to date with the latest security patches, and consider implementing security measures.

      Ojash

      Author

      Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

      Akshat

      Reviewer

      Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

      Share this article
      Shareable URL
      Prev Post

      How to Count the Number of Lines in a File [4 Simple Methods]

      Next Post

      How to Check Crontab Logs in Linux [2 Effective Methods]

      Leave a Reply

      Your email address will not be published. Required fields are marked *

      Read next