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)
- Difference Between Arch Linux and Kali Linux
- Disk Defragmentation in Operating System
- Checking Last Modification of a File On the Server in Java
- Space between two rows in a table using CSS?
- How to put images in a box without space using Bootstrap?
- Formatted text in Linux Terminal using Python
- Factorial calculation using fork() in C for Linux
- Encrypt/Decrypt Files in Linux using Ccrypt
- How to Browse From the Linux Terminal Using W3M?
- Using Lynx to Browse the Web From the Linux Terminal
- How to Fix Checksum Error Using fsck Command in Linux?
- How to Transparently Overlaid Two Directories Using UnionFS in Linux?
- How to Access All Users in Linux Using Different Commands?
- Encrypting and Decrypting the Files Using GnuPG in Linux
- Scientific Calculator Using awk Command in Linux
- Encrypting Files Using vim editor in Linux
- Deleting a User in Linux using Python Script
- Connecting to the Internet Using Command Line in Linux
- Getting System and Process Information Using C Programming and Shell in Linux
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.