du -sh /* 2>/dev/null # shows you the size of all the main folders, but you have to find the biggest one yourself.
du -h --max-depth=1 / 2>/dev/null | sort -hr | head -n 5 # It finds the sizes, automatically sorts them from biggest to smallest, and shows you just the top 5. It does all the work for you
Thanks shashi01 for that 2nd option, cause I just wanted to be able to
add water and stir
Glad it helped!
@Trevor you have mutliple options here. Three of famous options you can use are :
1.
du / -hxd 1 -t 1M | sort -hr | head -n5
this simply comes to mean : On the root filesystem (/), list all first-level subdirectories whose aggregated disk usage is ≥ 1 MB, show them in human-readable sizes, then sort them with the largest first.
or simply use this : du -ahx / | sort -hr | head
or use this same du command along with find command to check those large files :
find / -type f -exec du -Sh {} + | sort -rh | head -n5
2. use find command
find /dir-path/ -printf '%s %p\n'| sort -nr | head -10
3. use for loop in a bash script for finding largest size of all files and directories in the current directory and its subdirectories. You need to grep with numeric size in G( GB) , M( MB) and K ( KB) using same du command just tat grep part is grep [0-9]$i where i can be G/M/K
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.