Category: Linux Commands
- Home
- Category: Linux Commands
This article covers the usage of the DU command in Linux. In fact, the du command makes it convenient for Linux users to stay aware of their disk consumption and make an upgrade if required.
The sort command provides -h parameter allows to compare human-readable numbers (e.g., 10K 15M 1G etc). This helps up to compare the results of `du -h` and short them.
It takes the below form:
$ du -h * | sort -h
This will display the results in the ascending order by size.
You can also reverse this using -r to show results in descending order with the below command:
$ du -h * | sort -rh
The du -sh * command will display only a total for each argument as well as print sizes in human readable format (e.g., 1K 234M 2G).
The command takes the below form:
$ du -sh
The df command displays the amount of disk space available on the filesystem with each file name's argument.
The df command can be run by any user. Like many Linux commands, df uses the following structure:
$ df [OPTION]... [FILE]...
The df command primarily checks disk usage on a mounted filesystem. If you don't include a file name, the output shows the space available on all currently mounted filesystems.
While du reports files and directories disk usage, df reports how much disk space your filesystem is using.
The du command is used to estimate file space usage. To print sizes in human readable format such as 5K, 400M, or 3G, type the following commands:
du -h
du -h /tmp
du -h /home/user
The du command displays the files and directory sizes in a recursive manner.