fdisk Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

The fdisk command in Linux is a powerful disk management tool used by system administrators for creating and manipulating disk partition tables. With fdisk, you can create, delete, resize, and manage partitions on your hard disk effectively.

Syntax of fdisk Command in Linux

The basic syntax of the fdisk command in Linux is as follows:

Where:

  • options: These are flags that modify the behavior of the fdisk command.
  • device: This specifies the disk device that fdisk will operate on. It typically looks something like /dev/sda or /dev/hdb.
Sharpen Your Fundamentals with Free Learning

Options in fdisk Command in Linux

  1. -l: Lists the partition tables for the specified devices and then exits.

    For example -

    Output:

    This command lists out all the partitions on all the drives.

  2. -u: When listing partition tables, show sizes in sectors instead of cylinders.

    For example -

    Output:

    This command shows the disk's size in sectors rather than the default cylinders.

  3. -s: Display the size of a partition.

    For example -

    Output:

    This command will show the size of the /dev/sda1 partition in blocks.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Creating a new partition:

    Output:

    Explanation: Here, 'n' is used to create a new partition on the disk /dev/sda.

  • Deleting a partition:

    Output:

    Explanation: Here, 'd' is used to delete a partition on the disk /dev/sda.

Tips

  • Always backup important data before modifying disk partitions.

  • Use the 'p' command in fdisk to preview partition changes before saving them.

  • Use the 'm' command in fdisk for help if you get stuck.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of fdisk Command in Linux

  • Viewing disk details in sectors:

    Output:

    Explanation: This command shows the disk's size and partition information in sectors rather than the default cylinders.

  • Verifying the partition table:

    Output:

    Explanation: Here, 'v' is used to verify if the partition table on the disk /dev/sda is correct.

Conclusion

  • The fdisk command in Linux is a powerful tool for managing disk partitions.

  • It provides various options for listing, creating, deleting, and modifying partitions.

  • Always backup important data before using fdisk to modify partitions.

  • For help while using fdisk, use the 'm' command.