How to show disk usage in each subdirectory in Linux?

I have a directory /var/lib/docker

that contains several subdirectories:

/var/lib/docker$ sudo ls
aufs  containers  image  network  plugins  swarm  tmp  trust  volumes

      

I would like to know how big each directory is. However, using the command du

as below,

/var/lib/docker$ sudo du -csh .
15G .
15G total

      

I don't see a "breakdown" for each directory. In the examples I've seen at http://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/ , it looks like I should see this. How can I get this overview to see which directory is taking up the most space?

+3


source to share


5 answers


Use an asterisk to get information for each directory, for example:

sudo du -hs *

      



It will output something like below:

0       backup
0       bin
70M     boot
0       cfg
8.0K    data
0       dev
140K    docs

      

+6


source


Let the shell expand the contents of the directory:



du -h *

      

+2


source


Besides,

du -h <directory>

should do it.

+2


source


Call du

for each directory:

find . -type d | xargs du -csh

      

+1


source


Try using an argument max-depth

. It prints the total disk space usage for a directory (or file using --all

) only if it is less N

or less than the levels below the command line argument.

For example, the following command will show disk space up to 3 deep subdirectories

du --max-depth=3 -h

For information on N-levels use du --max-depth=N -h

, where N is a positive integer.

0


source







All Articles