I know I can find the name of my flash drive by going /media/user/nameOfFlashdrive
in the file manager. However, Is there a terminal command where I can enter the name of the flash drive and it will tell me where the drive is connected such as /dev/sdb1
?
Ubuntu – What’s the command for terminal to find the usb information
command lineusb
Best Answer
You can simply use:
This will output in my situation, running
where you can see both the device and the mount point. As you can see, I have two usb drives named
My Passport
Only get the device
The same, but with a more precise output:
Or, as suggested by @kos (thanks!) even simpler, using
lsblk
with the-l
option (which will leave out the└─
in the output, before the devices):Or (also as suggested by @kos), you could do without the
grep
command, only usinglsblk
andawk
:Explanation
lsblk
will list all your mounted devicesgrep <flashdrive>
will only list the line(s), matching with your device name, looking like:awk -F'[─ ]' '{ print $2 }'
will split the line by two delimiters:(which is the second character from └─)
and a space.
Subsequently, we can easily get the section we need.