The Linux terminal is crammed with commands that you can use to control and inspect just about any aspect of your machine. Be it checking your network status, user accounts or your disk storage.
In this article, we’re taking a look at the DF command and how you can use it to check disk space in Linux.
Also read: How to shutdown Linux from Command Line?
Using the DF command
The basic syntax for the DF command goes like this.
df [flags] filesystem
If you execute the command without any flags (or options), it’ll just output all mounted file systems with relevant information. The data is printed in the following format.
- Filesystem: The name of the file system.
- 1K-blocks: Describes the size of the filesystem in terms of 1K data blocks.
- Used: This shows how many of those 1K blocks are used.
- Available: This shows how many of those 1K blocks are available.
- Use%: This shows the percentage of used space out of total space.
- Mounted on: This shows the directory on which the filesystem is mounted or accessible.
If you’re looking for a specific file system, mention the name or the mount point in front of the df command. For example, if you want to see the root directory, this is the command you’ll use.
Also read: Linux Chown command explained
Showing Disk Space in human-readable format
As you can see, the df command’s output isn’t exactly beneficial. The command prints out disk space in terms of 1K memory blocks which is super easy for computers to understand, not so much for humans.
To display disk space in a human-readable format, use the -h flag with the command.
There are other flags that you can use to further filter information from the command.
- -t: Displays the fil;e system types along with the output.
- -x [file system type]: Allows users to limit the out to file system excluding the mentioned type.
- -i: Displays the inode usage of each file system,
Also read: Linux Sudo command explained