difference between df and du in Linux

Difference Between df and du command

In Linux, df command is used to get estimate of disk space usage while du command is used to get estimate of file space usage. In this article, we will learn the difference between df and du commands and when to use each of them. Both df and du commands are available in almost every Linux distribution.


Difference Between df and du command

du (disk usage) command is used to get space occupied by files and folders on a filesystem in Linux, while df (disk free) command is used to display the amount of free disk space on file systems for which user has access. du command is generally used to find the largest folders on your system, especially if you are trying to free up disk space. du command is simply used to monitor disk usage – free and used disk space.

df command uses disk blocks in filesystem metadata to calculate the required numbers unlike du command that shows disk usage as per directories.


What is df command? What does df command do?

df command is an abbreviation for disk free and is used to display the amount of free disk space accessible to user, for the drives the user has access to. df command is implemented using statfs or statvfs system calls. The df command reports only upto 90% of actual available disk space as 10% is reserved for system files. You can check out its options with the man command.

$ man df


What is du command? What does du command do?

du command is mainly used to get disk space occupied by directory or folder. As a result, it offers many options to customize du command’s output. For example, using -h option will display directory sizes in human readable formats. You can also use du command along with find command to display the disk size of directories that satisfy specific criteria. Here too you can use man command to check out its options.

$ man du

Please note, sometimes the output displayed by du and df commands can be different because there might be a running process with a file that was removed. In such cases, you need to reload or restart that process so that the file handle is closed.

That’s it. In this short article, we have seen the different between df and du commands in Linux.

Also read:

How to Create Startup Disk for Ubuntu
How to Install Fail2ban in Docker
Top Disk Utilities in Docker
How to Return Multiple Values in Python Function
How to Iterate Through List of Python Dictionaries

Leave a Reply

Your email address will not be published. Required fields are marked *