There's several commands for that actually. One can always filter out the output, using text processing tools, generally their output is small enough to read in one screenfull. Show blkidThis neat command by itself , as the name suggests, shows info about block devices. With -L you can search for specific device with a label (name). $ blkid -L DTSE9 /dev/sdb1dfThis neat command is part of coreutils package, shows the block size and usage of the "device files". It shows only informations about those devices that are mounted ( in other words, linked to a folder somewhere ). For instance, /dev/sdb5 115247656 84753976 24616332 78% /media/WINDOWSTells me that my windows partition on the second hard drive is linked to /media/WINDOWS partition. udisksctl$ udisksctl status MODEL REVISION SERIAL DEVICE -------------------------------------------------------------------------- Radeon R7 1.01 A22MD061520000172 sda TSSTcorp CDDVDW SU-208GB TF01 S16T6YEFB00NKH sr0Very convenient command that lists models and device file to which a disk is linked. In the example above my Radeon R7 SSD is linked to /dev/sda device. If we go into more details, udisksctl info -b /dev/sda will list lots of additional info , including size and symlinks. If we wanna go wild, udisksctl dump will produce verbose output on all the disks. parted and fdiskBoth commands are disks utilities, used for partitioning, resizing, and many more other fun things. Both however, require use of sudo. Both output great verbose information findThis is a more "hands on" approach. All the devices have a special device file under Linux ( remember Unix philosophy that says everything is a file ? It applies here the best ). Knowing that there are files /dev/disk/by-label we could search that directory, or we could just search /dev/disk in general. Definitely a tool that more advanced users can appreciate lsblkAlready covered by Jacob. mount$ mount | grep "DTSE9" /dev/sdb1 on /media/xieerqi/DTSE9 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)Lists all mounted filesystems. Can be filtered with grep to look for specific filesystem. It's analogous to doing grep 'DISKNAME OR UUID' /proc/mounts lshwThis command provides info about all the hardware on the system. In particular, you can view info about disks using lshw -c disk for whole device, or lshw -c volume for partitions, and you should see output with lines something like this: logical name: /dev/sdc1 logical name: /media/xieerqi/BA02-AF80
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 CommandThe 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. 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 CommandLsblk command is used to list all block devices on a Linux system. From the list, you can filter USB devices using the grep command. For example: lsblk | grep sd lsblk command list USB devicesTo retrieve additional information such as the UUID, manufacturer and filesystem type, use the blkid command as shown. sudo blkid blkid command output retrieve information on USB block devicesList USB Device Names Using fdisk CommandYou 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. sudo fdisk -lThe command will display detailed information about your USB volume including the partitions, size of the volume, sectors, and the filesystem type. List USB Devices Details using lsusb CommandThe lsusb command, also known as the “List USB” command, is used in Linux to list all the USB devices attached to the system. lsusb lsusb commandThe 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 | grep usb dmesg commandAlso, 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 driveList USB controllers and devices using usb-devicesThe 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 usb-devices command to list usb devicesConclusionIn 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. |