Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App

cfdisk command in Linux with examples

Last Updated : 10 Oct, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

cfdisk command is used to create, delete, and modify partitions on a disk device. It displays or manipulates the disk partition table by providing a text-based "graphical" interface.

cfdisk /dev/sda

Example: After running you get a prompt like this: Choose gpt from the list. Now you will see a partition table like this: Creating Partitions Using cfdisk:

  • See the available free space. Here we have 20 GB. Select NEW and create a new partition. Use up-down arrow keys to navigate and enter to select.
  • You can do many things with the free space, if you are installing a new system with a command line interface, you can see an option of using the selected space as primary partition. Example: Select the size 2GB. Enter -> and select primary. Similarly we can do a logical partition also.
  • After sizing the partition, select what type do you want, in my case, I am choosing Linux Swap.
  • After selecting the size and type write to the disk: You will see a prompt like this:

Options:

  • -h, --help: It displays help text and exit.
  • -L, --color[=when]: Colorize the output. The optional argument when can be auto, never or always. If the when argument is omitted, it defaults to auto. The colors can be disabled, for the current built-in default see --help output. See also the COLORS section.
  • -V, --version: Display version information and exit.
  • -z, --zero: Start with an in-memory zeroed partition table. This option does not zero the partition table on the disk; rather, it simply starts the program without reading the existing partition table. This option allows you to create a new partition table from scratch or from a sfdisk-compatible script.

Other command line commands: While using cfdisk you can use simple commands just like we use in vi editor for saving, inserting etc. The list of commands are as follows:

  • b: Toggle bootable flag of the current partition. It allows the user to select which partition is primary in the bootable drive. Just press b to see the results, no need of using ctrl.
  • d: It will delete the current marked partition, making a free space for new partition.
  • h: Will print the help screen, showing commands used .
  • n: Will create a new partition of the marked free space .
  • q: Will quit the program without writing partitions to the table.
  • s: Will fix the partitions order if they are now in proper array.
  • t: Will allow you to change the partition type, allowing you to select from the list.
  • u: Will dump the disk layout in a specified script file name
  • W: Will allow the user to write the data to the disk. The user will be asked if he or she wants to write or not by simply taking input "yes" or "no".
  • x: Will allow the user to hide or display all extra information of the partition.
  • Up-Arrow: Will allow the user to move the cursor to the previous partition, like moving up in the given table list.
  • Down-Arrow: This option allows the user to move the cursor to the next partition, next partition because every new partition is placed after the previous partition.
  • Left-Arrow: This option allows the user to enter previous menu item.
  • Right-Arrow: This option allows the user to enter to the next menu item.

Example: Sample output when we use "?" or "h"


M

Madhusudan_Soni
Improve
Article Tags :
  • Linux-Unix
  • linux-command
  • Linux-system-commands

Similar Reads

    builtin command in Linux with examples
    The builtin command in shell scripting is used to execute a shell builtin, passing it arguments, and also retrieving its exit status. Its primary use is to ensure that you can call the original functionality of a builtin command even when a function with the same name is defined. Syntaxbuiltin [shel
    2 min read
    bzcmp command in Linux with examples
    The bzcmp utility is used to invoke the cmp utility on bzip2 compressed files. All options specified are passed directly to cmp. As internally bzcmp calls cmp, We can pass the cmp command options to bzcmp. If only one file is specified, then the files compared are file1 and an uncompressed file1.bz2
    2 min read
    bzdiff command in linux with examples
    bzdiff command in Linux is used to compare the bzip2 compressed files. Bzcmp and bzdiff are used to invoke the cmp or the diff program on bzip2 compressed files. All options specified are passed directly to cmp or diff. If only one file is specified, then the files compared are file1 and an uncompre
    1 min read
    bzgrep command in Linux with examples
    bzgrep is a Linux command used to search for a pattern or an expression inside a bzip2-compressed file. This command simply passes it's arguments and the decompressed files to grep. Therefore, all the flags used in the grep command remain the same in bzgrep, since they are simply sent to grep as the
    2 min read
    bzip2 command in Linux with Examples
    bzip2 command in Linux is used to compress and decompress the files i.e. it helps in binding the files into a single file which takes less storage space than the original file used to take. It has a slower decompression time and higher memory use. It uses Burrows-Wheeler block sorting text compressi
    3 min read
    bzless command in Linux with examples
    bzless is a command similar to bzmore, but it has many more features. bzless does not have to read the entire input file before starting, so with a large file, it starts up faster than text editors like vi. bzless uses termcap (or terminfo on some systems), so it can run on a variety of terminals. S
    2 min read
    bzmore command in Linux with examples
    bzmore command in Linux is used as a filter for CRT viewing of bzip2 compressed files, which are saved with .bz2 suffix. In simple words, using 'bzmore', the content of the file can be viewed on the screen without uncompressing the file. bzip2 is a block-sorting file compressor which compresses file
    3 min read
    cal command in Linux with Examples
    The 'cal' command in Linux is a versatile tool that displays calendars directly in the terminal. If a user wants a quick view of the calendar in the Linux terminal, 'cal' is the command for you. Here’s a look at the usage and features of 'cal' command in Linux.What is the 'cal' command?cal command i
    2 min read
    case command in Linux with examples
    The case command in Linux is an essential tool for simplifying script logic, especially when multiple if/elif conditions need to be evaluated for a single variable. It offers a more readable and efficient way to execute commands based on pattern matching, making your shell scripts easier to maintain
    2 min read
    How to View the Content of File in Linux | cat Command
    The cat command in Linux is more than just a simple tool, it's a versatile companion for various file-related operations, allowing users to view, concatenate, create, copy, merge, and manipulate file contents. Let's see the details of some frequently used cat commands, understanding each example alo
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences