Using fdisk command in Linux

Using fdisk command in Linux


The fdisk is a command-line utitlity used for disk manipulation in Linux/Unix. It provides a text-based menu in the terminal for entering commands. By using fdisk you can perform operations such as you can create, view, resize, delete or move a partition on a hard disk.

When a partition on a hard drive is created, deleted, or modified it gets updated in the partition table. fdisk understand various partition tables including GPT, MBR, sun, BSD, etc.

In this article, we will see the uses of fdisk command on a Linux system along with some examples.

Syntax of fdisk command

fdisk [options] device


fdisk -l [device..]

Usage of fdisk command with examples

Some example of using fdisk command on a Linux system are given below –

1. View list of all disk partitions on a Linux system

To display the list of all disk partitions available on a hard disk on a Linux system, use the following command in your terminal –

sudo fdisk -l

As you can see in the image above there are eight partitions on this hard disk.


Use the command as given below if you want to display the list of partitions on a specific disk –

sudo fdisk -l /dev/sda

2. Display the list of all fdisk commands

If you want to display the list of fdisk commands then first run the given in your terminal –

sudo fdisk /dev/sda

This will ask for a command, enter m, and then press enter to see all the operation that can be done on /dev/sda.

Now you can enter a command to perform an operation on the disk.

3. Create a new partition

To create a new partition in a hard disk /dev/sda, first, run the given command –

sudo fdisk /dev/sda

Now this will prompt you to enter the command. Enter n for the new partition and then p if you want to create a primary partition otherwise enter e for an extended or logical partition.

Finally, enter w command to write the changes that you have made and then restart your system.

4. Delete a partition

To delete a partition from a harddisk /dev/sda, first, run the following command –

sudo fdisk /dev/sda

And it will prompt you to enter the command, enter this will ask you to enter the partition number. Enter the partition number and press the return key. After deleting the partition a message will be displayed that your partition has been deleted.

Enter the w command to write the changes on the hard drive.

To know more about the fdisk command and its usages see its manual page by using –

man fdisk


fdisk is a useful command for manipulating the partitions on a hard drive. Don’t use fdisk unless you don’t know what are you doing otherwise you may end up with deleting a partition that has important data on it.

Now if you want to say something on this topic then write us in the comments below.

Previous recommended install image for Pinebook Pro?
Next How to resize swap partition in Linux?

About author

You might also like

Commands 0 Comments

Using rm command to delete files and directories in Linux

As already we have discussed how to create a file or directory in Linux or Unix systems. Now if you want to remove them then Linux provides a separate command

Commands 0 Comments

Using systemctl command in Linux

The systemctl command in Linux is responsible for controlling a widely adopted “systemd” init system and service manager. The init is the first process that starts when you power on

Commands 0 Comments

Using finger command in Linux

Finger command in Linux is used to display the details of a user. It includes information like login name, username, login time, idle time, home directory, etc. This command is


No Comments Yet!

You can be first to comment this post!

Leave a Reply