df

Disk usage

Just posting a handy little trick to get your disk usage from the command line.

While the df command will show you what the disk utilization for your partitions, sometimes you need more specific details, like which files and folders are taking up all of your space.

Here is how I do this:

  1. df -Pacmx --max-depth=1 . |sort -g

This is kind of awkward to type out all the time, so you create an alias.

  1. echo "alias dus=\"df -Pacmx --max-depth=1 . |sort -g\"" >> ~/.bashrc

Now type

  1. source ~/.bashrc

From any directory, you can now type "dus" without the quotes to see all the files and directories sorted by size. It should also be noted that df is rounding up to the nearest megabyte.

One final note, the flags I used are specific to the GNU version of these utilities. You BSD folks will have to adjust the df and sort options.

Syndicate content