As a newbie, one of the many things you should master in Linux is identifying the devices attached to your system. It could be your computer’s hard disk, an external hard drive, or removable media such as a USB drive or an SD memory card.

Using USB drives for file transfer is super common these days, and for those (new Linux users) who prefer using the command line, learning how to identify a USB device name is really important, especially when you need to format it.

Once you attach a device to your system, like a USB, it’s usually auto-mounted to a directory, normally under /media/username/device-label. From there, you can access its files just like any other folder. However, this isn’t the case with a Linux server. In server environments, you typically need to manually mount a device and specify its mount point.

Linux identifies devices using special device files located in the /dev directory. Some common ones you’ll find include /dev/sda or /dev/hda, which represents your primary (master) drive. Each partition on the drive is represented by a number, for example, /dev/sda1 or /dev/hda1 for the first partition, and so on.

ls /dev/sda*
List All Linux Device Names
List All Linux Device Names

Now, let’s check out a few command-line tools you can use to identify USB device names:

1. Find Out Plugged USB Device Name Using df Command

To see each device attached to your system along with its mount point, use the df command (which checks disk space usage):

df -h
Find USB Device Name Using df Command
Find USB Device Name Using df Command

2. Use lsblk Command to Find USB Device Name

The lsblk command (list block devices) shows all block devices attached to your system:

lsblk
List Linux Block Devices
List Linux Block Devices

3. Identify USB Device Name with fdisk Utility

fdisk is a powerful tool that prints the partition table of all block devices, including USB drives.

sudo fdisk -l
List Partition Table of Block Devices
List Partition Table of Block Devices

4. Determine USB Device Name with dmesg Command

dmesg is an important command that prints kernel messages, which include details about USB devices when they’re plugged in.

dmesg
dmesg - Prints USB Device Name
dmesg – Prints USB Device Name

That’s all for now! In this article, we’ve covered several different ways to find the name of a USB device from the command line.

If you know other methods or have any thoughts to share, feel free to drop them in the comments below.

Similar Posts