There are numerous ways of checking Linux system disk space. A third-party app that shows the available disk space or by command-line way via the Linux Terminal two of which are df and du, where du is disk space used and df is disk space free.
1. Using du Command
Using du command for checking disk space. du stands for “Disk Usage”, using this command we can check directories disk usage.
$ du [OPTION HERE]... [FILE HERE]...
For help, we can use
$ du --help
For checking disk usage on a particular directory and display there size in a human-readable format.
$ du -h [PATH TO DIR]
For checking disk usage, and sort by first 3 directories that are using most maximum disk space.
$ du -a [PATH TO DIR].. | sort -n -r | head -n [NUMBER TO FILES/DIR]
2. Using df Command
Using df command for checking disk usage. df is an abbreviation for “disk free”, it displays the amount of available disk space for file systems.
$ df [OPTIONS]... FILESYSTEM...
Showing disk space usage for the file system
To show all the information for the disk space usage on all the file system “-a” is used.
$ df -a
To show disk space usage of the file system for human “-h” is used.
$ df -h
To fetch the data just for the single directory.
$ df -hT [DIR ]..
To see disk space usage and display specific columns.
$ df -H --output=size, used, avail
Display the disk space usage for the file system in bytes we will use “-k” and to display it in megabytes we will use “-m”.
$ df -k
$ df -m