Hello, I’m Liang Xu.

At work, it is common to encounter disk overflow, especially after a server has been running for N years, it will be filled with all kinds of garbage files, such as: compilation intermediate files, packaged image files, log files, and so on.

Don’t ask me how I know, my last company server is like this, I need to delete some useless files every day, in order to make some space to work.

How do you check the available disk space on your Linux system? Here are five common commands I use at work.

The df command

The df command is short for disk-free and is used to view the available and used disk space in Linux. This command has the following common options:

  • df -h: Displays disk space in human-readable format (otherwise defaults to bytes, which is not intuitive)
  • df -a: contains all file systems

  • Df -t: displays the disk usage and the file system type of each block (for example, XFS, ext2, ext3, BTRFS, etc.)

  • Df -i: displays used and idle inodes

If you prefer to use graphical interfaces rather than typing code, you can implement software called Disks to GNOME desktop (GnOMe-disk-Utility) to implement this information.

Once Disks are started, you can view all Disks detected by your computer, and then click partition to see details about it, including used and free space.

Du command

The du command is the abbreviation of disk useage. It displays the usage of files, folders, and other disks in the default kilobyte size. Common options are as follows:

  • Du -h: displays the disk usage of all directories and subdirectories in human-readable format

  • Du -a: displays the disk usage of all files

  • Du -s: displays only the total value and lists only the final sum value

Similarly, on the GNOME desktop, there is a software called Disk Usage that makes it easy to see Disk Usage. On the KDE desktop, the corresponding software is Filelight.

In both programs, disk usage is mapped to a series of concentric circles, with the base folder (usually your /home directory, but you can customize it) in the middle, and each outer ring representing a deeper directory level. Hover over any location to get detailed information about the disk usage.

Ls – al command

The ls command is well known for listing the entire contents of a particular directory and its size.

The stat command

The stat command is used to display the size and other statistics of a file or directory or file system.

Linux fdisk -l command

Fdisk -l displays the disk size and partition information.

These commands are the ones I use most often to check the available disk space. They are all built into Linux and require no additional installation. Third-party tools, such as Disks and Ncdu, can display disk space utilization directly.

Which command do you like to use most? Let’s discuss it in the comments section


Finally, recently, many friends asked me for Linux learning roadmap, so I stayed up for a month in my spare time according to my own experience, and sorted out an e-book. Whether you are interviewing or self-improvement, I believe will help you!

Free to everyone, just ask everyone to point to me!

Ebook | Linux development learning roadmap

Also hope to have a small partner can join me, do this e-book more perfect!

Have a harvest? Hope the old iron people come to a triple whammy, give more people to see this article

Recommended reading:

  • Dry goods | programmers advanced architect necessary resources free of charge
  • Book | programmers must read classic books (hd PDF version)

Welcome to pay attention to my blog: good Xu Linux tutorial network, full of dry goods!