how to list disk partitions in linux from command line

It is very likely that the hard disk or hard drive on your machine is divided into multiple partitions, as it allows for it to be accessed independently. There are several different reasons as to why you should partition your disk and it probably is already partitioned for you if you have not done it yourself.

If you looking to list your disks rather than the disk partitions, then that is done differently. Here we will just look at how you can list your disk partitions.

Many times you would want to list disk partitions on the system across all devices. This might be before you are deciding on a new partition format or maybe after you have done a partition. It might also be that you just want to list the partitions so that you can see the disk usage or the partition format in each of them.

All of the command listed below will need to be executed as the super user. You can either log in as the root or super user before executing them, or use sudo. Also, you can specify a specific device, such as /dev/sda or /dev/hdb as a command line argument to print out partitions on the specified device.

parted

GNU Parted or parted is a command line utility to manipulate disk partitions. In addition to the ability to create, delete and modify partitions, it can also be used to list the current partition table. As with most commands in this list, the –list or -l command line option will list disk partitions.

bash# parted -l

lsblk

lsblk is the Linux command that lists all the block devices on the system. It can list information about all partitions available or just the specified devices. It prints out information in a tree like fashion which is easy to read. You can also specify the fields that you want displayed.

bash# lsblk

The above command will list all devices and partitions available. If you want to list only certain information on a specific device, then use the command format shown below.

bash# lsblk -o NAME,FSTYPE,SIZE /dev/sdb

fdisk

fdisk is a user interface driven Linux program to manipulate disk partition table. It can be used to list the partition table as well. The -l option will list the partition table for the specified device. In order to list disk partitions on all devices, do not specify a device.

bash# fdisk -l

The command above will list partitions on all devices. If you want to list disk partitions on just a specified device, say /dev/sda then use the device name as the command line argument to fdisk.

bash# fdisk -l /dev/sda

sfdisk

sfdisk is similar to fdisk in listing the partitions. The default output is slightly different from fdisk, but pretty much prints out similar information. You can use the -l command line option just as the fdisk command.

bash# sfdisk -l

cat /proc/partitions

Another option to list disk partitions is to print out the partitions device file in the proc directory. This contains limited information than that printed out by other commands, but is a good option when other commands and utilities are not available.

bash# cat /proc/partitions

mount

mount is another Linux utility that can be used as well. Actually, mount will show you only the disks and partitions that are currently mounted. Assuming that all your partitions are mounted, it will list disk partitions but will not display the ones that are not mounted.

bash# mount

gparted

If you prefer to have a graphical interface opposed to a command line utility, then gparted is a good option. Running gparted with out any arguments will display all the partitions that are on the devices. You can also change devices from the GUI to view partitions on different disks.

All the commands and utilities mentioned above is not only good for listing all disk partitions, it can also be used for creating and modifying disk partitions as well. You can see how to list all your hard disks in the system after you have partitioned your disk.