Is there any difference between the commands df and du in UNIX operating system. If so what is it? A example on each of the above commands would help me understand this in detail.
Printable View
Is there any difference between the commands df and du in UNIX operating system. If so what is it? A example on each of the above commands would help me understand this in detail.
du: This command prints the disk usage (in Kb) of each directory and it's sub
directories. By default it starts from the current directory, but supplying
the name of a directory after the command will make it start from that
directory.
df: This command tells you the amount of free space on all mounted file systems,
or you can specify the name of a device you want to check.
1.The du command display disk usage statistics and the df command is to display free disk space.
2.'df' returns the space amounts based on filesystem allocation data. 'du' traverses the filesystem and adds the space used by the files it finds.
Example :$ du -h /tmp
The -h option provides "Human-readable" outpu i.e. you will see it in Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.
Example:$ df -h
outpuy can be
Filesystem Size Used Avail Capacity Mounted on
/dev/wd0a 938M 43.0M 848M 5% /
They work in a very different manner.
du is disk space used.
df is disk space free.
du does its work by examining the files or directories you name.
df looks at the files or directories you name and determines what file system contains them,
Then it examines the global data of the file system itself.