Run the following command to find out top biggest directories under /home partition
# du -a /home | sort -n -r | head -n 5
The above command displays the biggest 5 directories of my /home partition.
If you want to display the biggest directories in the current working directory, run:
# du -a | sort -n -r | head -n 5
Let us break down the command and see what says each parameter.
du command: Estimate file space usage.
a : Displays all files and folders.
sort command : Sort lines of text files.
-n : Compare according to string numerical value.
-r : Reverse the result of comparisons.
head : Output the first part of files.
-n : Print the first ‘n’ lines. (In our case, We displayed first 5 lines).
Some of you would like to display the above result in human readable format. i.e you might want to display the largest files in KB, MB, or GB.
# du -hs * | sort -rh | head -5
The above command will show the top directories, which are eating up more disk space. If you feel that some directories are not important, you can simply delete few sub-directories or delete the entire folder to free up some space.
To display the largest folders/files including the sub-directories, run:
# du -Sh | sort -rh | head -5
Find out the meaning of each options using in above command:
du command: Estimate file space usage.
-h : Print sizes in human readable format (e.g., 10MB).
-S : Do not include size of subdirectories.
-s : Display only a total for each argument.
sort command : sort lines of text files.
-r : Reverse the result of comparisons.
-h : Compare human readable numbers (e.g., 2K, 1G).
head : Output the first part of files.
# du -a /home | sort -n -r | head -n 5
The above command displays the biggest 5 directories of my /home partition.
If you want to display the biggest directories in the current working directory, run:
# du -a | sort -n -r | head -n 5
Let us break down the command and see what says each parameter.
du command: Estimate file space usage.
a : Displays all files and folders.
sort command : Sort lines of text files.
-n : Compare according to string numerical value.
-r : Reverse the result of comparisons.
head : Output the first part of files.
-n : Print the first ‘n’ lines. (In our case, We displayed first 5 lines).
Some of you would like to display the above result in human readable format. i.e you might want to display the largest files in KB, MB, or GB.
# du -hs * | sort -rh | head -5
The above command will show the top directories, which are eating up more disk space. If you feel that some directories are not important, you can simply delete few sub-directories or delete the entire folder to free up some space.
To display the largest folders/files including the sub-directories, run:
# du -Sh | sort -rh | head -5
Find out the meaning of each options using in above command:
du command: Estimate file space usage.
-h : Print sizes in human readable format (e.g., 10MB).
-S : Do not include size of subdirectories.
-s : Display only a total for each argument.
sort command : sort lines of text files.
-r : Reverse the result of comparisons.
-h : Compare human readable numbers (e.g., 2K, 1G).
head : Output the first part of files.
No comments:
Post a Comment