Skip to content

Instantly share code, notes, and snippets.

@JohnRDOrazio
Last active November 1, 2023 10:08
Show Gist options
  • Save JohnRDOrazio/d5806a7ee9074f82704f937f19a96476 to your computer and use it in GitHub Desktop.
Save JohnRDOrazio/d5806a7ee9074f82704f937f19a96476 to your computer and use it in GitHub Desktop.
List files/folders by size in descending order, limit 20
sudo du -hsx --exclude=/{proc,sys,dev,run} /*| sort -hr | head -n20
@JohnRDOrazio
Copy link
Author

When checking other paths, you would use -hax rather than -hsx, e.g.:

sudo du -hax /var| sort -hr | head -n20

@JohnRDOrazio
Copy link
Author

better yet, limit to depth one:

sudo du -hax -d 1 /var | sort -hr | head -n20

@JohnRDOrazio
Copy link
Author

this actually seems to work for root directly too, without needing all the excludes...

sudo du -hax -d 1 / | sort -hr | head -n20

@JohnRDOrazio
Copy link
Author

This works well when checking current directory:

sudo du -hxs ./* | sort -hr | head -n20

@JohnRDOrazio
Copy link
Author

However if you also want to include hidden folders in the results, such as git folders, use this:

sudo du -ahd1 | sort -hr | head -n20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment