To manage disk space on a Linux server effectively, you often need to identify large files and directories. Here are several useful commands to find and analyze large files and directories.
1. Using the du
Command
The du
(Disk Usage) command displays the disk space used by files and directories. Use it with various options to list large directories and files.
Find the Largest Directories #
To find the largest directories within the current directory, use
du -ah --max-depth=1 | sort -hr | head -n 10
-a
: Shows sizes for both files and directories.-h
: Displays human-readable sizes (e.g., KB, MB).--max-depth=1
: Limits output to the first level.sort -hr
: Sorts output in human-readable reverse order.head -n 10
: Displays the top 10 largest entries.

Find Large Directories on Entire Filesystem #
To find the largest directories on the whole filesystem:
sudo du -ah / | sort -hr | head -n 10

Find Specific File Sizes in MB #
To find files larger than a specific size (e.g., 100 MB):
sudo find / -type f -size +100M -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'
-type f
: Searches for files only.-size +100M
: Looks for files larger than 100 MB.-exec ls -lh {}
: Lists each file with its size in human-readable format.awk '{ print $NF ": " $5 }'
: Prints the file path and size.

2. Using the find
Command
The find
command is very powerful for locating large files based on various conditions.
Find Files Larger than 1 GB #
To locate files larger than 1 GB, use:
find / -type f -size +1G 2>/dev/null
/
: Specifies the root directory. Replace with a specific path to narrow the search.-type f
: Searches for files only.-size +1G
: Finds files larger than 1 GB.2>/dev/null
: Suppresses error messages for directories you don’t have permission to access.

3. Using the ls
Command for Directory Contents #
- For a quick list of large files in a specific directory,
ls
can be handy.
Sort Files by Size in a Directory #
To list files in a directory sorted by size:
ls -lhS /path/to/directory | head -n 10
-l
: Displays details (size, date, etc.).-h
: Shows human-readable sizes.-S
: Sorts output by file size, largest first.head
-n 10
: Displays the top 10 largest files.

4. Using the ncdu
Command (Recommended for Interactive Use) #
- Install
ncdu
if it’s not available:
sudo apt install ncdu # For Debian/Ubuntu
sudo yum install ncdu # For CentOS/RHEL

- If available,
ncdu
(NCurses Disk Usage) is an interactive tool that’s particularly useful for finding large files and directories.
sudo ncdu /

- Use the arrow keys to navigate directories and identify the largest files or folders interactively.
- Press
q
to quit.zz
Summary #
These commands are quick and efficient ways to locate large files and directories on a Linux server. By combining du
, find
, ls
, and ncdu
, you can easily identify the largest files and manage your disk space effectively.