-1

I would like to find out what were top consuming files or folders in linux, which consumes most space (in human readable form - in MB or in GB) files or folders should be recently modified - for example within last month.

I suspect this is combination of du -exec, sort, ls command, but can be specify which ?

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62
  • I have the strong feeling that this has been asked and answered many times before on the internet. Please do some research before you post a question! Besides that, the question is off topic on SO. – hek2mgl Aug 09 '17 at 10:53
  • I'm voting to close this question as off-topic because the OP showed no own effort to solve the problem – hek2mgl Aug 09 '17 at 10:54
  • there were similar questions, but not with frequently modified date. So this is new question. I have tried to solve this on my own using stack overflow suggestions, but unfortunately without any result, that's why this post. – TarmoPikaro Aug 09 '17 at 11:17

4 Answers4

1

With CLI

du -hsc * | sort -h

What each option means for du:

h: show sizes in human readable format (1K, 1M, 1G, ...)
s: summarize: display only a total for each argument
c: also display a grand total

If you want GUI, you can use disk usage analyzer

sheplu
  • 2,937
  • 3
  • 24
  • 21
  • I have some older CentOS distribution, is it possible to survive without sort -h option, as it's not available (sort: invalid option -- h) – TarmoPikaro Aug 09 '17 at 03:08
1

Top consuming files modified within last month:

find "$PWD" -type f -mtime -30 -exec du -sh '{}' + | sort -rh | head

Top consuming folders modified within last month:

find "$PWD" -type d -mtime -30 -exec du -sh '{}' + | sort -rh | head

If your sort version doesn't support the -h option, you can try:

find "$PWD" -type f -mtime -30 -exec du -s '{}' + | sort -nr | head | cut -f2- | xargs -d'\n' du -sh
MauricioRobayo
  • 2,207
  • 23
  • 26
  • I have some older CentOS distribution, is it possible to survive without sort -h option, as it's not available (sort: invalid option -- h) – TarmoPikaro Aug 09 '17 at 03:08
  • Please see updated answer. Also this might help you: https://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size – MauricioRobayo Aug 09 '17 at 08:23
  • Third command looks like working as I wanted. Takes a lot of time to execute on root however, needs to be pation. – TarmoPikaro Aug 09 '17 at 12:40
0

If you want really the top 10, you can use:

du -h | sort -h | tail -10

In CentOS, without sort -h, you can try this:

du -h | sort -nr | tail -10
Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
0

You can use tools such as https://www.diskreport.net/ to follow the graph of your disk usage history

mick
  • 197
  • 3