Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To check the space used by a directory, run du -sh /path; use du -sh . for the current directory. To find the largest directories on the root filesystem, run sudo du -xhd1 / | sort -hr. These GNU du commands work on Ubuntu 16.04 and 18.04, though both releases have passed standard security maintenance: see Canonical’s Ubuntu 16.04 lifecycle page, Ubuntu 18.04 lifecycle page, and release cycle for support details.
Check the size of one directory
Run:
du -sh /home/username
For the directory you are currently in, use:
du -sh .
The output will resemble 2.8G /home/username; the value varies by system. -s (or --summarize) prints a single total, while -h (or --human-readable) displays readable units. You can check several paths at once with du -sh /home /var /tmp.
du recursively walks directory entries and estimates space consumed, normally using filesystem blocks rather than simply adding logical file lengths. Without options, it can print totals for multiple directories and uses 1024-byte blocks unless another block-size setting is active. The Ubuntu 16.04 du manual, Ubuntu 18.04 du manual, and GNU Coreutils du documentation describe its options and accounting.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsFind the largest directories and drill down
To list a directory and its immediate children, use --max-depth=1 (or the shorter -d1):
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
du -h --max-depth=1 /var
Sort the results largest first:
sudo du -xhd1 /var 2>/dev/null | sort -hr
Here, sort -h understands human-readable size suffixes and -r reverses the order. Repeat the scan inside the largest result—for example, if /var is large, inspect /var/log or /var/lib with the same command. --max-depth=1 shows the specified directory and entries one level below it; depth zero is equivalent to a summary.
For a root-filesystem scan, use:
sudo du -xhd1 / | sort -hr
-x means “stay on one filesystem,” preventing traversal into other mounted filesystems. This matters under /, where virtual filesystems such as /proc, /sys, and /run, as well as separate partitions or external and network mounts, can make a scan misleading or slow. GNU documents this behavior as processing only the filesystem containing the specified argument.
Use -x again while drilling into a path when you want to stay within that path’s filesystem. If /home is mounted separately, inspect it independently rather than attributing its usage to the root filesystem.
Recommended Free Tools
Locate individual large files
Ordinary du output focuses on directories. Add -a to include files, then limit the results to the largest entries:
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
sudo du -ahx /var 2>/dev/null | sort -hr | head -n 10
This traverses every file under the chosen path, so it can be slow on a large tree. Start with a one-level directory scan and narrow the path before running a full search. To see hidden files too, scan the directory itself with du; it includes dotfiles during recursion. A manual glob such as du -sh * may omit hidden entries.
Do not delete an item just because it is large. Logs, databases, application data, and package files may be required; first identify which program owns the data and what cleanup method is safe.
Choose a useful starting location
Common areas worth checking include:
/var/logfor logs./var/cache/aptfor downloaded package archives./var/libfor application and package data./homefor user files, hidden configuration, and caches./tmpfor temporary files./usrfor installed programs and shared data.
Use a focused scan rather than repeatedly traversing everything:
sudo du -xhd1 /var 2>/dev/null | sort -hr
For a user-readable home directory, you may not need sudo. If permissions block the scan, run it with sudo. While diagnosing, it is often better to leave errors visible; redirecting 2>/dev/null hides them and can make an incomplete scan look clean.
Rank #3
- Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Understand du, df, and inode usage
| Question | Command | What it tells you |
|---|---|---|
| Which files or directories are large? | du |
Estimated usage found by walking directory entries. |
| How full is a mounted filesystem? | df -h |
Filesystem-level used and available space. |
| Are there too many files for the available inodes? | df -i or du --inodes |
Inode usage rather than byte or block usage. |
df reports filesystem space usage, while du estimates usage visible in the scanned directory tree; they are not guaranteed to match. GNU’s df documentation and du documentation describe the different measurements.
Differences can come from deleted files still held open by a process, filesystem metadata or reserved blocks, permissions, other mounts, hard links, sparse files, or snapshot and copy-on-write behavior. To check a filesystem and its visible tree together:
df -h /home
sudo du -xsh /home
If df shows substantially more usage than du accounts for, one possible cause is an unlinked file still held open by a running process. Check with:
sudo lsof +L1
Identify the owning process before taking action. Restarting a service can release such space, but may interrupt users or work; do not restart it without understanding the operational impact.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
A filesystem can also run out of inodes while bytes remain. Check df -i, or locate directories with many inodes using:
sudo du --inodes -h --max-depth=1 /
Allocated usage versus apparent file size
By default, du reports space based on allocated filesystem blocks. To compare that with logical file lengths, use --apparent-size:
du -sh /path
du -sh --apparent-size /path
The values can differ for sparse files, block rounding, filesystem overhead, indirect blocks, and hard-linked files. A sparse file can have a large logical length while occupying fewer blocks. GNU du also supports -b, equivalent to apparent size with one-byte blocks; it is not a report of allocated disk blocks.
Useful options and safer variations
| Option | Purpose | When to use it |
|---|---|---|
-a |
Include files as well as directories. | Find individual large files. |
-x |
Stay on the filesystem containing the argument. | Scan / without traversing other mounts. |
--max-depth=N or -dN |
Limit how many directory levels are reported. | Get a readable first-level breakdown. |
-c |
Add a grand total for the listed paths. | For example, du -shc /home /var /tmp. |
-k or -m |
Display fixed-size blocks of 1024 bytes or 1 MiB. | Prefer fixed units for scripts or numeric sorting. |
--apparent-size |
Report logical file size rather than allocated blocks. | Investigate sparse files or compare measures. |
--inodes |
Count inodes instead of blocks. | Investigate inode exhaustion. |
--exclude=PATTERN |
Omit names matching a pattern. | Reduce noise in a targeted scan; test patterns before using in cleanup scripts. |
-L |
Follow all symbolic links. | Use only when you specifically need target traversal. |
-P |
Do not follow symbolic links. | This is the default behavior. |
-D |
Follow only symlinks supplied as command-line arguments. | Use when an argument itself is a link whose target should be counted. |
GNU du does not follow symbolic links by default. Following links may traverse unexpected trees or produce totals that look duplicated, so leave the default in place unless needed. By default, hard-linked files are not counted repeatedly; --count-links changes that behavior and can inflate totals.
Best Value
- [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
- 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
- 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
- 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
- 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
For readable numbers sorted by size, use sort -h. For numeric sorting with fixed 1024-byte blocks, use:
sudo du -k --max-depth=1 / | sort -nr
When passing a filename that begins with a dash, terminate options with --, for example du -sh -- --filename-starting-with-dash.
Terminal and desktop alternatives
du is already supplied by Ubuntu’s coreutils package and is well suited to SSH sessions, headless machines, repeatable checks, and scripts. For interactive terminal browsing, ncdu offers a navigable view, but may not be installed by default. On older Ubuntu releases, its package may not be available from normal mirrors; do not assume installation will succeed:
sudo apt update
sudo apt install ncdu
sudo ncdu -x /
Ubuntu desktop users can also use a graphical disk-usage analyzer when they prefer a visual overview.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

