The fdisk command is a text-based utility for viewing and managing hard disk partitions on Linux. It's one of the most powerful tools you can use to manage partitions, but it's confusing to new users.
This tutorial will go through the basics of using fdisk to manage a partition table. After using fdisk, you'll have to use a mkfs command to format new partitions with a file system.
Sudo vs. Su
On Ubuntu, Linux Mint or other Ubuntu-derived distributions, the fdisk and mkfs commands must be prefixed with sudo. On distributions that don't use sudo, use the su - command first to get a root shell, then type every command without sudo.
List Partitions
The sudo fdisk -l commands lists the partitions on your system.
You can add a disk's device name to list only partitions on it. For example, use the following command to only list partitions on the first disk device:
sudo fdisk -l /dev/sda