Get the device name of connected USB disk

You can do it with lsblk command.

lsblk -l -o name,tran gives

NAME TRAN
sda  sata
sda1 
sdb  usb
sdc  usb
sr0  sata

-l stands for "list" format, so it's easier to parse. Otherwise, you would get a tree format like this:

NAME   TRAN
sda    sata
└─sda1
sdb    usb
sr0    sata

Specifying other flags will give you more information like FSTYPE, LABEL, UUID, MOUNTPOINT and many other, just run lsblk --help to see all options.

You may want to use --paths --noheadings --scsi flags to have output printed like this:

sata   /dev/sda
usb    /dev/sdb
usb    /dev/sdc
sata   /dev/sr0

and then grep over the input to filter out those lines with usb at the beginning of the line.


Do lsusb, it gives the name of the devices connected via the USB bus.

As in:

$ lsusb
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0421:0802 Nokia Mobile Phones CA-42 Phone Parent
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

See also man lsusb

Description

lsusb is a utility for displaying information about USB buses in the system and the devices connected to them.