Tuesday, May 12, 2015

How To Use Flash drive From Terminal

Usually by default ubuntu mounts your flash drive
on /media/<user_name>/<drive_name>

For e.g. my flash drive name is "usb_drive"
             my user name is also "tarun" on ubuntu
             So I can access my flash drive contents on media/tarun/usb_drive



How to access flash drive from terminal ?

Well you can directly go to the above directory
/media/<your_username>/<drive_name> using cd command and access your drive if it is already mounted.

What if your device is not mounted ?

  •  You need to know what the drive is called to mount it. 
                                       sudo fdisk -l



Here you can see all your disks and their partitions
From above shot , I have two disk /dev/sda & /dev/sdb.
/dev/sda is my hard drive and it has one partition /dev/sda1
/dev/sdb is my flash drive and it also has single partition /dev/sdb1

Now i know that my flash drive is called "/dev/sdb1" on ubuntu as of now.

  • Create a mount point
Create a new directory in /media so you can mount the drive onto the filesystem:

                            sudo  mkdir /media/usb


  •  Mount your flash drive
                           sudo mount /dev/sdb1 /media/usb


  •   When you are done, unmount your flash drive
                            sudo umount /media/usb