How to use any pendrive in linux system.

Pendrive is a very important data storage device in our day to day life. But we often got in hustle to make things work between our pc and pendrive or usb device. That's why today I am going to show you exactly what you should do to make things work with your pendrive and linux pc. Remember, this process also work for any ssd, hdd, mmc etc external drives.

First, type lsblk to check that your usb device is detected or not. If not detected try inserting again.
lsblk command gives us a list of partitions of all the drives avaiable to the pc. Suppose you got a 32GB pendrive. So, you should look for the corresponding device. Your usb device will look something like sdx, where on the place of x, can be a or b or any alphabet.
Now, we need to format the disk. This will wipe all the data you have in that pendrive. To format the usb, type:

Now and later, always replace x with your accordingly(eg. sda/sdb). Now we need to create a partition. For that: Then, type g and hit enter for GPT partition, then n for new partion, then hit enter for all the defaults. And at last press w to write and exit.
Now, lsblk command will show you a partition under your device(eg. sdx1). To format this partion: After formatting, it's time to mount this in a directory. For that, we need to create a directory first. Then, to mount: Now, lsblk will show the mount point(/mnt/usb) right beside your device partion.
Congratulations, you have successfully mounted a usb device. Use this as your applications.

Now, if you want to keep this device always mounted, you need to do one more things. Because, shutting down your pc will cause unmount the device. Then you need to mount again(sudo mount /dev/sdx /mnt/usb). So, if you want to keep this device always attached to your pc, not manually do this again and again, then you need to mount this on /etc/fstab file. Type this command in the terminal: You will get a string like UUID=xxxx... Copy the hexcode after UUID. We need to put this in /etc/fstab file. So, open that file with this command: Be careful with everything you do in this file, because this is the file that is responsible to boot up your computer. Add this line at the last of the file. Also, replace xxxx with the full hexcode you got from blkid. Now, save the file and exit the editor. To, make the sure that everything is ok, type: If any error arrives, I suggest you to check the UUID again. If no error, then congratulations you have successfully added a usb device or hard drive permanently to your pc.