-2

When I use the unix df command to return the disk usage, I get the following reported

/dev/sda1                       30929148 30530112    399036  99% /

How get what is using the disk space.

Is there a way to determine as to which directories are taking up space?

gstukelj
  • 2,291
  • 1
  • 7
  • 20
Pete Long
  • 107
  • 2
  • 11

1 Answers1

1

You can using du (disk usage). For example:

➜  ~ du -sh /usr/* 2>/dev/null 
587M    /usr/bin
276M    /usr/include
5,4G    /usr/lib
444M    /usr/lib32
0       /usr/lib64
96K     /usr/local
0       /usr/sbin
3,1G    /usr/share
4,0K    /usr/src

To sort use sort -h.

Edit

Works with directories (which can be mountpoints).

du -sh $(lsblk -no MOUNTPOINT /dev/sda1)/* 2>/dev/null
ashunt
  • 64
  • 3
  • so i tried du -sh /dev/sda1/* 2>/dev/null. this returned nothing The /dev/sda1 is a filesystem. Can the du command be run on filesystem ? – Pete Long Oct 26 '19 at 10:33
  • Thanks ashunt. Unfotunately, the du command does not report anything for me. Would you know of any other commands i can try out to find which directories are consuming the disk space / – Pete Long Oct 26 '19 at 10:43
  • Hi ashunt, Just tried your last suggestion ( du -sh $(lsblk .. ), and got a list back of what seems to be filenames in order of biggest disk space consumer under the filesystem /dev/sda1. Is that correct understanding ? – Pete Long Oct 26 '19 at 10:53
  • That list is the disk usage of files and directories in the mountpoint of `/dev/sda1`. I think is what you asked for. – ashunt Oct 26 '19 at 10:57
  • Hi ashunt I think this is prefect, I can use your latest ( du -sh $(lsblk .. ) command to identify the directories under /dev/sda1. Than to use ( du -sh /usr .. ) on each directory to understand disk usage under each directory . Many thanks for a really quick resolution on my query. – Pete Long Oct 26 '19 at 11:04
  • @PeteLong if this solved your problem, please mark as solution – ashunt Oct 28 '19 at 09:45