Keeping an eye on your server’s disk usage is an essential part of system administration. Running out of disk space can cause application crashes, database corruption, and other serious problems.
In this guide, we’ll cover several ways to check disk usage on an Ubuntu 24.04 Server, from quick commands to interactive tools.
🔹 1. Check Overall Disk Usage
The simplest way to view disk usage is by using the df
command:
df -h
What it does:
df
displays information about the file system’s disk space usage.- The
-h
flag shows sizes in a human-readable format (MB/GB).
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 38G 21% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
This gives a quick overview of all mounted partitions and how much space is used and available.
🔹 2. Check Disk Usage by Directory
If you want to see which directories are consuming the most space, use:
du -sh /*
Explanation:
du
stands for “disk usage”.-s
summarizes each directory’s total.-h
makes the output human-readable.
You’ll get a list of directories (like /var
, /home
, /usr
, etc.) along with their total sizes.
🔹 3. Find the Largest Directories or Files
To quickly locate what’s eating up space, you can combine du
with sort
:
du -h / | sort -rh | head -n 10
This command lists the top 10 largest directories starting from the root (/
).
You can also use it on a specific folder, for example:
du -h /var | sort -rh | head -n 10
🔹 4. Use an Interactive Disk Usage Viewer (Recommended)
For an easy, interactive way to browse disk usage, install ncdu:
sudo apt install ncdu -y
sudo ncdu /
Use the arrow keys to navigate through directories and identify which ones are taking up the most space.
This tool is especially useful on servers without a GUI.
🔹 5. Check Usage of a Specific Filesystem
If you just want to check how much space a specific mount point (like /home
) is using:
df -h /home
💡 Bonus Tip: Set Up Disk Usage Alerts
You can automate disk monitoring by setting up email or script-based alerts when disk usage crosses a certain limit. This helps prevent system downtime and keeps your server running smoothly.
✅ Final Thoughts
Monitoring disk usage is a simple yet crucial habit for server health. Whether you prefer basic commands like df
and du
or interactive tools like ncdu
, Ubuntu 24.04 offers everything you need to stay in control of your storage space.
Tags: Ubuntu 24.04, Linux Server, Disk Management, System Administration, DevOps