Skip to content

Instantly share code, notes, and snippets.

@emrahoruc
Created August 6, 2018 08:11
Show Gist options
  • Save emrahoruc/adf4a8ce491f5162274e7fe2f1521f5b to your computer and use it in GitHub Desktop.
Save emrahoruc/adf4a8ce491f5162274e7fe2f1521f5b to your computer and use it in GitHub Desktop.
How to Find Out Top Directories and Files (Disk Space) in Linux
# Find Biggest Files and Directories
# Run the following command to find out top biggest directories under /home partition.
du -a /home | sort -n -r | head -n 5
# To display the largest folders/files including the sub-directories, run:
du -Sh /home | sort -rh | head -5
# PARAMETERS
# du command: Estimate file space usage.
# a : Displays all files and folders.
# sort command : Sort lines of text files.
# -n : Compare according to string numerical value.
# -r : Reverse the result of comparisons.
# head : Output the first part of files.
# -n : Print the first ‘n’ lines. (In our case, We displayed first 5 lines).
# Source https://www.tecmint.com/find-top-large-directories-and-files-sizes-in-linux/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment