Reputation: 766
I've been using "du -hs ~/" to get the size of my total home directory with outputs 20GB, and I've been trying to where large files that I can delete to free up some space. However, when using "du -hs ~/*" I get numerous outputted files but they don't sum to 20GB. There are a few hidden files but they aren't shown.
How can I print out the size of hidden files, and also locate the largest files/directories via command line?
Thank you!
Upvotes: 12
Views: 24714
Reputation: 61375
Combining some of the above answers together to get a more desirable result using:
du -sh $(ls -A) | sort -h
displays size of hidden files and directories and then sorts it in an ascending order.
Upvotes: 1
Reputation: 10574
To size all the files in home directories including hidden files
du -sh $(ls -A)
du -sh .[^.]* *
To size only normal files
du -sh *
To size only hidden files
du -sh .[^.]*
Upvotes: 20
Reputation: 11
find ~/ -maxdepth 1 -type d -exec du -hs {} \;
Running this command will display the disk usage summary (du -hs) for each hidden directory found.
Upvotes: 1
Reputation: 17422
The problem lies not with du
but with how the shell resolves *
- it does not include files that start with a period. To remedy, just mention those files explicitly:
du -hs ~/* ~/.*
In order to find the largest of those files, simply pipe the output to a sort
command, with an optional tail
appended:
du -hs ~/* ~/.* | sort -h | tail
Upvotes: 13