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
- Linux Virtualization : Linux Containers (lxc)
- How to put images in a box without space using Bootstrap?
- Space between two rows in a table using CSS?
- Artifical Intelligence in Space
- Clone a stack without extra space
- Program to replace every space in a string with hyphen
- Why Linux is Better?
- Linux vs Unix
- while command in Linux with example
- Permissions in Linux
- od command in Linux with example
- who command in Linux
- Run Levels in Linux
- 10 Best Linux VPS Hosting
- Some useful Linux Hacks
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.