Quick Links
Whether you’re installing Linux on a new system or adding new storage, there are plenty of commands to manage the disks on your system. These commands can help you get a handle on your hard drives and SSDs in Linux.
11df
You can use the df command to see how much free space you have on your disk. Just run it at the command line without any arguments to see the available space of all mounted devices:
You can view the free space of the device where a filename is mounted by specifying it as the argument. For example, to see the free space where the root directory (/) is mounted:

By default, df reports the size by blocks, which varies depending on the system. you’re able to use the -h option for “human-readable” output, reporting in units such as gigabytes that you might recognize more easily.
10du
du is similar to df, but it reports the space that files take up in the directory where it’s invoked. If no argument is given, it will list the files in the current directory. This is handy for finding large files and directories.
du works recursively. This means that if one of the files listed is a directory, du will list the files in that directory. If there are subdirectories in that listing, those become part of the input as well. This means that on most Linux systems that have lots of nested subdirectories, du will generate a lot of output.

As with df, du reports block sizes by blocks by default, but can use more human-friendly units with the -h option.
9fdisk
fdisk is a stalwart of Linux as a basic tool for partitioning hard drives. This is a part of any Linux installation, since it wants its own partition and you’ll likely want a swap partition as well.
you’re able to even have partitions for certain directories like the home directories. You might not run it by itself, but a lot of installation programs use fdisk or something like it behind the scenes. You might use it if you’re installing a more technical distro like Arch. You might also use it if you want to partition an external or additional drive, or even ona recovery USB stick.

Don’t use fdisk to repartition a mounted drive. You could lose data.
8GNU Parted
GNU Partedis the GNU Project’s take on a partitioning tool. It adds a relative bit of user-friendliness. It’s designed to help prevent dangerous operations that could result in data loss. The menu designs seem more comprehensible than fdisk’s.
To run parted, you just run it from the command line

Replace “X” with the name of the device you want to partition. Again, you would likely want to avoid partitioning a mounted device.
7swapon and swapoff
swapon and swapoff are tools to enable and disable devices that have been set up for swapping. “Swapping” is a term where the device, typically a hard drive, is used to hold pieces of the working memory, letting the computer use more RAM than is physically in the machine, at the expense of performance. Pieces of the memory are broken into pages, which are “swapped out,” copied out of the RAM to the swap partition, or “swapped in,” or copied back in, as needed.
You can use the swapon and swapoff commands to enable and disable a swap device at will. This is handled automatically on most distros, but if you’reon something like Archor Gentoo you’ll have to do this manually. You might also want to use this if you get a new disk. After setting up your partition, you can enable it with the swapon:

Or to disable it:
You can use the -a option to enable or disable any swap partition defined in /etc/fstab.
6cfdisk
cfdisk is another attempt at a user-friendlier version of fdisk. The key difference from fdisk is that cfdisk runs in a text user interface, or rather a “curses” interface. It’s similar to other full-screen programs like Vim.
Instead of using cryptic commands, you navigate through menus to list partitions and create new ones. It’s a lightweight alternative to programs like GParted, which require a graphical interface.

Again, you should avoid trying to repartition a mounted drive, and there’s a bright red message in the screenshot saying so. Don’t worry, this was just a listing of partitions for demonstration in this article. No partitions were harmed in the making of this piece.
5mkfs
When you’ve created your partitions, they’re useless until you turn them into a filesystem. The filesystem scheme determines how files will actually be stored on the drive. That’s where the mkfs command comes in. This lays out the file system on the partition. This is something that the installation program will take care of normally, but either you’re running Arch or another more technical distro, or you’ve added a drive to your system.
There are several filesystems you may use, but Ext4 is one of the most popular options, since it’s widely supported and reliable. To set up a new Ext4 partition, use mkfs.ext4

4Filesystem Utilities
mkfs is a good example of the kind of disk utilities that ship with certain filesystems. These are tools that are meant to work with specific filesystems instead of Linux as a whole.
A good example of this is e2fsprogs, which are designed for the Extended Filesystem family of filesystems, of wich Ext4 is the most recent example.
Most of the utilities that ship with e2fsprogs are mainly of interest to developers and distro maintainers. One you might encounter is fsck, pronounced “fisk,” which stands for “file system consistency check.” It runs at boot time and checks if the system shutdown cleanly. If it didn’t, such if the power was just turned off instead of using the shutdown option, it will try to bring the filesystem back into consistency. Fortunately, on modern systems, this is quick since they use a journal to keep track of changes to the filesystem.
Other filesystems have fsck and similar utilities.
3sfdisk
sfdiskis a similar tool to the other disk partitioning tools you’ve seen. One key difference of sfdisk from the other disk partitioning utilities is that it’s meant to be used in scripts. Distro developers could use it to automate partition creation, but if you frequently add and remove drives, you can use it yourself to automate disk repartitioning.
Again, this is something that you don’t want to use on a mounted filesystem. The program will abort with another bright red error message if you try.
2partprobe
partprobe is a utility that tells the Linux kernel about changes to the partition table. If you’ve used one of the partitioning tools mentioned earlier, the kernel might not have been informed about any changes. A lot of the time, this is a detail that your distro will take care of. If you have made changes to your drives or partitions, you can use this tool to update the running kernel without a reboot.
For example, to run it on a partition:
There’s not much in the way of output, but in Linux, a sign that a program did its job isoften saying nothing at all.