The hard disk is the main component of the system to store the data permanently. We can install single or multiple disks for data storage, and several commands are utilized to list your computer’s disk and partition of disk details.
This article will explain these command line methods for listing the Linux disks:
- List Disks Using lsblk Command
- List Disks Using df Command
- List Disks Using cfdisk Command
- List Disks Using lshw Command
- List Disks Using fdisk Command
- List Disks Using hwinfo Command
- List Disks Using sfdisk Command
- List Disks Using /dev/disk File
Method 1: List Disks Using lsblk Command
The lsblk (list block devices) utility shows the details of the input and output block devices, including the disks. Let’s execute the lsblk command to view the system block devices:
The output shows the block devices supported by the system that includes the disk along with the partitions (one disk named sda having three partitions, “sda1”, “sda2”, and “sda3”) in the system as highlighted.
Method 2: List Disks Using df Command
The df (disk free) is mainly used to check the available free disk space. It can be used to list the file system that includes the disks. Let’s run the df command to view the result:
$ sudo df
The output shows the file systems (including disks and partitions) and other relevant information.
To display the df command output in human-readable mode, use the “h” option as shown in the below command:
$ sudo df -h
The filesystem of the disks and other details are shown in the output.
Method 3: List Disks Using cfdisk Command
The cfdisk is a useful command to list disks in Linux, and it shows the disk along with its partition details in a graphical way. Let’s list the disks with the cfdisk command by running the following command:
$ sudo cfdisk
The output shows only 1 disk is available in the system “/dev/sda”, and it has three partitions which are “sda1”, “sda2” & “sda3”.
Method 4: List Disks Using lshw Command
The lshw (list hardware) command lists the system hardware configuration in Linux. We can use the lshw command with the “class” option and provide it “disk” value to view the system disks details as written below:
$ sudo lshw -class disk
The output shows the disk available in the system and its partitions.
Method 5: List Disks Using fdisk Command
The fdisk (format disk) command can be used to create or manipulate the disk partitions in the system hardware. We can list the number of disks available in the system with the “l” (list) option of the fdisk command:
$ sudo fdisk -l
The output shows different details of the disk and partitions that include the disk with its partitions.
Method 6: List Disks Using hwinfo Command
Another command to check the physical disks in the system is “hwinfo” hard disk info. It is widely used to check the hard details of the system. To list the disk details specifically, we can use the “disk” option with the hwinfo command:
$ sudo hwinfo --disk
The output lists several details about the disk, such as unique disk ID, disk model, disk-mounted file system, etc.
Method 7: List Disks Using sfdisk Command
The sfdisk is commonly used to manipulate the partition table. We can use this command to list all the hard disks and their partitions with the “l” (list) option, as shown below:
$ sudo sfdisk -l
The output shows several file system details in which the disk detail is listed with its partitions as shown in the output.
Method 8: List Disks Using /dev/disk File
The “/dev/disk” file stores the disk information by default in the Linux operating system. We can use the “ls” command with the “/dev/disk” to list all the details about the disks and disk partitions. To list the partition details, we can sort the “/dev/disk” file by using the “partuuid” option as shown below:
$ ls -l /dev/disk/by-partuuid
The output shows three partitions are available in the system “sda1”, “sd2” and “sda3”. We can sort the “/dev/disk” file with the below options as well:
Several commands are utilized to list disks in Linux, i.e., lsblk, df, cfdisk, lshw, fdisk, hwinfo, and sfdisk. These commands print the basic to advanced level information about each disk (and partition if applicable). This post has briefly explained all these commands to list disks on Linux.