I was looking through my system with du -sch ./*
to find the big useless files I may have stockpiled with no reason, when I found this:
$ du -sch ./*
du: cannot read directory ‘./drbunsen/.gvfs’: Permission denied
du: cannot read directory ‘./drbunsen/.cache/dconf’: Permission denied
18G ./drbunsen
18G total
$ cd drbunsen/
$ du -sch ./*
601M ./Desktop
20K ./Documents
598M ./Downloads
4.0K ./flash
4.0K ./Music
8.0M ./Pictures
4.0K ./Public
4.0K ./Templates
4.0K ./Ubuntu One
8.0K ./Videos
11G ./VirtualBox VMs
6.9M ./workspace
12G total
How do I make hidden files visible? du -sch ./.*
gives the same result as du -sch ./*
.
Use
in your home folder.
Alternatively, the command I use most frequently is
Easy to install if needed:
I have same question in coreutils mailing list, because it was hard to me to remember this weird command by @don.joey. And Bob Proulx proposed better, more natural command:
du -ahd1 | sort -h
When you run that same command inside the directory, it is not including the hidden files which start with
.
in the count. If you have Steam for example installed, it default to installing games under~/.local/share/Steam/
and it itself is installed there as well.Under bash you apparently need to run
du -sch .[!.]* *
as it does not properly expand the.*
glob. Underzsh
or other shells,du -sch * .*
should work, as.*
should be expanded to include the list of all hidden files in the current directory.This also works to show hidden files and dirs:
I don't think the
du
utility has a command line switch to process hidden files by default.One way of achieving this is to use the
find
utility to find the hidden files that you are interested in and then run thedu
utility on each entry:This gives you additional flexibility as you may only be interested in directories:
Or you may want to see all hidden files and directories deep to the current working directory:
It's not much harder to sort the output, so you can easily identify large hidden files that could help you save disk space: