Use of du & df commands (with examples)
Last updated on March 12th, 2018 at 07:35 pm
In this article I will discuss du & df commands. Both du & df commands are important utilities of Linux system & shows disk usage of Linux filesystem. Here we will share usage of both commands with some examples.
(Recommended Read: Files transfer using scp & rsync commands)
du command (short for disk usage) is useful command which is used to find disk usage for files & directories. du command when used with various options provides results in many formats.
Some of the examples are mentioned below:-
1- To find out summary of disk usage for a directory with all its sub-directories
$ du /home
Output of the command shows all the files & directories in /home with block size.
2- Disk usage with file/directory sizes in human readable format I.e. in kb, mb etc
$ du -h /home
3- Total disk size of a directory
$ du -s /home
It will total size of /home directory.
df command (short for disk filesystem) is used to show disk utilization for a Linux system.
Some examples are shared below.
1- To display information of device name, total blocks, total disk space, used disk space, available disk space and mount points on a file system.
2- Information in human readable format
$ df -h
Above command displays information in human readable format.
3- Display information of a particular partition
$ df -hT /etc
Using -hT with a target directory will show information of /etc/ in human readable format.
Though there are many more options that can be used with du & df commands, but these should get you started. If you don’t find what you are looking for here then you can always refer to man pages for the concerned command.
Also, read my other posts HERE where i have shared some other important & frequently used Linux.
And as always your comments/queries are really appreciated, so please leave your comments/queries down below & I will get back to you.