Ubuntu – Using the terminal, how can I see the directory (and files) in an external HDD attached via USB port

directoryhard drive

Using the terminal, how can I see the directory (and files) in an external HDD attached via USB port? (I am a beginner so would appreciate simple instructions. I have tried to find the answer through "search" – there are similar questions with answers that I tried to bend to my needs but could not – sorry).

Best Answer

The topic that you're looking for is mounting . In the file manager you just click on the button to open it or detach the drive, but behind the scenes it uses udisksctl . Big advantage of this command is that it mounts as your user, and you don't have to specify whole lot of options, unlike the classic mount command.

For instance, to mount your usb drive, find device path with either lsblk or sudo blkid and then mount like so, for example,

udisksctl mount -b /dev/sdb1

Of course remember to replace sdb1 with the actual device name you want to mount.

Once the device is mounted successfully, it will be reported where it is mounted. For example,

skolodya@ubuntu:$ udisksctl mount -b /dev/sdb5
Mounted /dev/sdb5 at /media/xieerqi/0ca7543a-5463-4a07-8bbe-233a7b0bd625.

Then you could navigate to /media/$USER/folder-name and start exploring files and folders

Related Question