GO KALI FREE
Disk Commands

fdisk Linux Command

Manipulates disk partition table (create, delete, resize partitions).

What does fdisk do?

Manipulates disk partition table (create, delete, resize partitions).

Syntax

fdisk [options] device

Practical example

sudo fdisk -l

Questions about fdisk

How do I list all partitions?

Use `sudo fdisk -l` to list all disk partitions and their sizes. Use `sudo fdisk -l /dev/sda` for a specific disk.

How do I create a new partition?

Use `sudo fdisk /dev/sdb` then press `n` to create a new partition. Follow the prompts to set size and type.

How do I delete a partition?

Use `sudo fdisk /dev/sdb` then press `d` to delete a partition. Select the partition number to delete.

How do I see partition table of a disk?

Use `sudo fdisk -l /dev/sda` to display the partition table including partition types, sizes, and sectors.

What is the difference between fdisk and parted?

fdisk works with MBR partition tables (max 2TB). parted supports both MBR and GPT and can handle larger disks.

How do I change partition type?

Use `sudo fdisk /dev/sdb` then press `t` to change the partition type. Enter the hex code for the desired type.

How do I write changes with fdisk?

Use `w` to write changes and exit. Use `q` to quit without saving. Always double-check before writing.

How do I see disk info without root?

Use `lsblk` or `lsblk -f` to see disk and partition information without needing root privileges.

Related Disk Commands

du

Estimates file and directory space usage (disk usage).

mount

Mounts a filesystem (attaches a device to the directory tree).

df

Reports disk space usage for all mounted filesystems (human-readable with -h).

umount

Unmounts a filesystem (detaches a mounted device from the directory tree).

ncdu

Interactive disk usage analyzer with a terminal UI (ncurses-based).

mkfs

Creates a filesystem (formats) on a disk partition.