- 1 1. Prerequisite Knowledge: Storage Structure and Mounting in Linux/Ubuntu
- 2 2. Basic Method to Check Capacity with Commands
- 3 3. How to Check Disk Space with a GUI (Visual) (for Ubuntu Desktop)
- 4 4. Investigation Procedures and Countermeasures for Low Disk Space
- 4.1 4.1 Check for Signs of Disk Pressure
- 4.2 4.2 Step 1: Get an Overview of Overall Usage (df)
- 4.3 4.3 Step 2: Investigate Which Directories Are Consuming Space (du)
- 4.4 4.4 Step 3: Delete Unnecessary Files and Caches
- 4.5 4.5 Step 4: Mitigate Bloat Caused by Applications and Logs
- 4.6 4.6 Step 5: Fundamentally Resolve by Resizing or Adding Disks
- 4.7 4.7 Regular Checks to Prevent Recurrence
- 4.8 4.8 Summary: Priorities for Disk Space Management
- 5 5. Advanced Tips (Useful Techniques & Cautions)
- 5.1 5.1 Automate Regular Disk Checks
- 5.2 5.2 One-liner to Find Large Files
- 5.3 5.3 Alias Frequently Used Commands
- 5.4 5.4 Continuously Observe Disk Usage Changes (Monitoring)
- 5.5 5.5 Beware of Permission Barriers
- 5.6 5.6 Considerations for SSD/HDD Environments
- 5.7 5.7 Systematize Capacity Management to Prevent Recurrence
- 5.8 Summary
- 6 6. FAQ (Frequently Asked Questions)
- 6.1 Q1. What is an easy way to check the current free space on Ubuntu?
- 6.2 Q2. How can I check the size of each directory?
- 6.3 Q3. df and du: What is the difference?
- 6.4 Q4. How can I check free space using a GUI?
- 6.5 Q5. When “Disk is full” appears, what should I delete first?
- 6.6 Q6. I’ve heard Snap apps can consume a lot of space. What should I do?
- 6.7 Q7. /var or /home are too large: what should I do?
- 6.8 Q8. du takes a long time. Are there ways to speed it up?
- 6.9 Q9. How can I prevent disk space shortages from recurring?
- 6.10 Q10. What are the options for expanding capacity?
- 6.11 Q11. Can I check disk usage without root privileges?
- 6.12 Q12. How can I check disk usage in a non‑GUI (server) environment?
- 6.13 Q13. Is there a risk of breaking the system when checking disk usage?
- 6.14 Q14. Are there any tricks to save disk space?
- 6.15 Q15. What tools do you recommend for monitoring disk usage?
- 6.16 Summary
1. Prerequisite Knowledge: Storage Structure and Mounting in Linux/Ubuntu
When checking storage capacity on Ubuntu (and many Linux‑based OSes), there is a basic structure you should understand correctly. This chapter organizes the following concepts that readers often get confused about.
- Meaning of device partition
- Mount (mount) and mount point
- LVM (Logical Volume Management) Basics
- Typical configuration example in Ubuntu
Below, we will explain step by step.
1.1 Basics of Devices and Partitions
Device (Physical & Logical Disk)
In Linux, each storage device is treated as a device file. For example, HDDs, SSDs, USB drives, etc. are represented with names such as /dev/sda
, /dev/sdb
, /dev/nvme0n1
.
The trailing alphabet of a device name (a
, b
, c
…) indicates the order in which the system detected it.
Partition
You can use a single physical device as is, but generally it is divided into multiple logical sections (partitions). By partitioning, you can separate and manage the OS portion, data portion, log area, etc.
For example, /dev/sda1
, /dev/sda2
denote partitions. This means “the first/second partition on device sda”.
A filesystem is created on these partitions to store actual data.
(Example explanation of partitions in Linux) Engineer’s Entrance
Partitions have partition table formats such as MBR (old method) and GPT (new method), each with its own constraints and advantages.
1.2 Mounting and Mount Points
Mount (mount)
To make a filesystem usable, a “mount” operation is required. This is the task of linking a partition (or logical volume) to a specific directory (mount point).
Without mounting, you cannot access the data on the partition.
For example, even if /dev/sda1
has an ext4 filesystem, unless you run mount /dev/sda1 /mnt/data
, you cannot manipulate its contents under /mnt/data
.
Mount Point
The directory where you mount is called a “mount point”.
Typical example:
/
/home
/var
/boot
Thus, configurations that assign multiple partitions to different mount points according to the OS and usage are commonly used.
In Ubuntu and many Linux‑based OSes, the /etc/fstab
file contains the settings for which device/UUID to mount where (automatic mounting at boot).
1.3 Overview of LVM (Logical Volume Management)
Using only partitions can make it difficult to flexibly change disk configurations later. The mechanism used for this is LVM (Logical Volume Manager).
Basic Components of LVM
- Physical Volume(PV: Physical Volume) A physical disk or partition corresponds to it.
- Volume Group (VG: Volume Group) A layer that bundles multiple PVs to create a virtual large area.
- Logical Volume (LV: Logical Volume) A region logically extracted from the VG as appropriate. The file system is created on this LV.
This hierarchical structure makes it easy to later expand/shrink logical volumes or add physical disks and combine them.
Benefits and Considerations of Using LVM
Benefits
- Flexible capacity expansion and contraction
- Can use multiple disks together
- Can build an environment that is easy to support snapshots (for backup purposes)
Considerations
- Settings and operations are somewhat complex
- Risk of data loss due to accidental operation
- The expansion procedure differs from non-LVM environments.
When installing Ubuntu, there is often an option to select LVM, but it is also common not to use it depending on the purpose and management policy.
1.4 Typical Configuration Examples in Ubuntu
The configuration varies depending on the environment where Ubuntu is used, but here are some commonly seen patterns.
Single Partition Layout (Simple Layout)
In the minimal configuration, everything is packed into the root (/
). Fewer partitions make it simple, but later splitting or expanding can become difficult.
Partitioned Layout Example
A configuration that splits into multiple partitions as shown below is often used:
/
/home
/var
/boot
- Swap area (physical or swap file)
With such a configuration, it is easier to prevent logs or caches from growing large and burdening the system.
LVM + Logical Volume Layout
As a more advanced example, you can use LVM as follows.
- Physical Disk → PV
- Integrate multiple PVs into a VG
/
/home
/var
- In the future, adding and expanding other LV is possible.
If you use this method, operations such as adding disks or expanding logical volumes can be performed flexibly.
2. Basic Method to Check Capacity with Commands
In Ubuntu, checking disk capacity with commands is the most reliable and flexible method.
With commands, even in server environments without a GUI, you can accurately see how much each disk is used and which directories are consuming space.
Here we focus on the basic df
, du
commands, and also introduce auxiliary tools.
2.1 df
Command to Check the Entire File System
df
Overview
df
(disk free) is a command that displays total disk usage and free space.
It is the most common way to check capacity in Linux environments, including Ubuntu.
Basic Usage
df -h
When you run this command, the capacities of all file systems are listed in human‑readable units (K, M, G).
The meaning of the main columns is as follows.
Column name | meaning |
---|---|
Filesystem | Target device name (e.g., /dev/sda1) |
Size | Total capacity of the file system |
Used | Used Capacity |
Avail | Remaining free space |
Use% | Usage rate (%) |
Mounted on | Mounted directories (e.g., /, /home, etc.) |
Commonly Used Options
Option | Explanation |
---|---|
-h | Display capacity in MB / GB units (useful at required level) |
-T | Also display file system types (ext4, xfs, etc.) |
--total | Add a total row at the end |
df -h /home | Display only file systems that include a specific directory |
Example
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 100G 55G 40G 59% /
/dev/sda1 512M 120M 392M 24% /boot
tmpfs 16G 32M 16G 1% /run
From this output, you can instantly see how much each area is used.
Cautions
- Unmounted partition
df
- If snap packages () are taking up space, you need to check separately.
- There are also mount points that are not visible unless you have root privileges.
2.2 du
Command to Check Directory‑Level Usage
du
Overview
du
(disk usage) is a command that examines capacity at the directory or file level.
df
provides an overall view, whereas du
is suited for finding where the heavy usage is.
Basic Usage
du -sh /home
In this example, the total usage of the /home
directory is displayed in a human‑readable format (-h).
Commonly Used Options
Option | Explanation |
---|---|
-s | Show only the total (omit details) |
-h | Automatically convert units for easier viewing |
--max-depth=1 | Display usage list under the specified directory |
-c | Display the total at the end |
--exclude=PATTERN | Exclude specific folders (e.g., cache) |
Example (Overall Comparison)
sudo du -h --max-depth=1 /var
Example output:
1.2G /var/log
2.5G /var/lib
800M /var/cache
4.5G /var
In this way, you can quickly see which folders are consuming space.
Advanced: Sort by Size Descending
du
and sort
can be combined to easily identify large directories.
sudo du -hsx /* | sort -rh | head -10
This command calculates the usage of each folder directly under the root and displays the top 10.
It is very effective for finding the “space‑eating culprits” across the system.
Cautions
- If the directory hierarchy is deep, processing may take time.
- If you don’t have root privileges, the capacity of some directories will not be displayed correctly.
- Even with high‑speed storage such as SSDs, measurements on the scale of tens of gigabytes can take several minutes.
2.3 Other Useful Helper Commands and Tools
lsblk
: Check Block Device Layout
lsblk
lsblk
displays disk devices and their partition layout in a tree format.
It is a handy command that lets you visually understand the relationship between capacity and mount points.
Example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 99.5G 0 part /
ncdu
: Interactive Disk Usage Analysis Tool
du
If you want a more intuitive way to use du, ncdu
(NCurses Disk Usage) is recommended.
Installation is as follows.
sudo apt install ncdu
Run:
sudo ncdu /
You can navigate with the up/down keys to open and close folders and investigate which directories are consuming space.
Because it can be used visually without a GUI even on servers, it is popular among administrators.
find
Command Combination
If you want to search only for large files, use find
.
sudo find / -type f -size +1G
This command searches for all files larger than 1 GB.
It helps identify unnecessary large files such as logs and virtual images.
2.4 Which Method to Use (Comparison Summary)
Purpose | Command example | Features |
---|---|---|
Check the overall system free space | df -h | Understand at the file system level |
I want to know the size of a specific folder | du -sh /path | Show detailed size |
I want to find the place that is consuming capacity. | `du -hsx /* | sort -rh |
Check device configuration | lsblk | Visualize partition relationships |
Search for large files | find / -type f -size +1G | Extract by size condition |
3. How to Check Disk Space with a GUI (Visual) (for Ubuntu Desktop)
Ubuntu includes a convenient graphical tool (GUI) that can check disk space without using the terminal, provided as standard or optional.
Here we introduce the two main methods.
- Confirm with Ubuntu’s standard “File Manager (Nautilus)”
- “Check with the Disk Usage Analysis Tool (Baobab)”
Let’s look at the features and how to use each.
3.1 Check Free Space with the File Manager (Nautilus)
Standard Ubuntu Method
If you are using Ubuntu Desktop, the easiest way to check disk free space is to open the File Manager (Nautilus).
- Click the “File” icon from the left dock (app launcher)
- Check the displayed in the upper right or lower left
- Information such as “△△ GB used out of 〇〇 GB” or “〇〇 GB remaining” will be displayed at the bottom.
This view lets you see the free space on the system drive immediately.
How to View Details from Properties
Right‑click the folder or drive icon and select [Properties],
you can also view detailed used and free space for that folder.
Useful when you want to intuitively see the size of specific directories (e.g., /home
or /Downloads
).
Advantages and Limitations
Merit | Constraint |
---|---|
Easy with just a click | The entire system and hidden areas are hard to see. |
Easy to use even for beginners | /var/log |
The GUI is convenient for getting a quick overall sense, but for deeper analysis the Baobab tool is effective.
3.2 Disk Usage Analyzer (Baobab)
What is Baobab?
“Baobab” (official name: Disk Usage Analyzer) is a graphical tool available by default in Ubuntu,
which shows how much space each folder uses as pie charts or treemaps.
It is installed by default on many systems, but if it is not present you can install it with the following command.
sudo apt install baobab
How to Launch
- Enter “Disk Usage” in Activity (search in the upper left)
- Click to launch Disk Usage Analyzer (Baobab)
- After startup, select “Scan Folder” or “Scan Entire File System”
After a short scan, the usage of each directory is displayed visually as a pie chart or tree view.
Example Display (Image)
- The further you go to the outer edge, the deeper the directory hierarchy becomes,
- The size of each area is shown by the area of the pie chart.
It quickly shows visually which folders have grown large.
Main Interaction Features
Functionality | Explanation |
---|---|
Specify scan target | /home |
Tree View | View folder structure and size in a list |
Identification of Unnecessary Files | Easily discover large folders at a glance |
right-click → open | Open the target directory directly in the file manager |
Advantages and Cautions
Advantages
- Intuitive understanding even for beginners with graphical display.
- Easier to decide on deletion and organization
- If you start with root privileges, you can also analyze the system area.
Cautions
- Scanning the entire system takes time.
- Due to permission restrictions, some folders may not be measured accurately.
- On large-capacity disks, memory usage also increases.
3.3 Check Disk Information with GNOME Disk Utility
Ubuntu includes a standard app called GNOME Disks (Disk Utility).
It is a tool for inspecting the disk structure itself and can show information beyond free space.
- Device name (e.g., /dev/sda)
- Types of file systems (ext4, NTFS, etc.)
- mount point
- Usage and Free Capacity Graph
How to launch:
- Search for ‘Disk’ in Activity
- Open GNOME Disk
- Select a disk from the list on the left
A visual gauge shows the usage rate, and you can see the same information as the df
command graphically.
3.4 Choosing Between GUI and Commands
On Ubuntu Desktop, GUI tools alone are sufficient for managing storage.
However, for accurate troubleshooting and server management, command‑line tools such as df
and du
are essential.
Situation | Recommended tools |
---|---|
I want to roughly check available space. | File Manager (Nautilus) |
I want to analyze which folder is large | Baobab (Disk Usage Analysis) |
I want to check the device configuration | GNOME Disks |
Server and remote environment | df , du , lsblk , ncdu |
3.5 When No GUI Environment Is Available (for Server Users)
If you are operating in an environment such as Ubuntu Server where GUI is not installed,
Baobab and the file manager are unavailable.
In that case, you can use the df
, du
, and ncdu
commands introduced in the previous chapter,
to perform detailed storage analysis even in a text‑based environment.
Summary
By using the GUI, you can check storage and identify cleanup points with just a click.
Especially, Baobab is a versatile tool usable by everyone from Ubuntu beginners to advanced users.
Using the methods introduced in this chapter makes everyday storage monitoring much easier.
4. Investigation Procedures and Countermeasures for Low Disk Space
When using Ubuntu, disk space can become constrained due to prolonged use and the accumulation of package updates.
If low disk space is left unchecked, updates may fail, logs cannot be recorded, and the system can become unstable.
procedure for investigating the causes of low disk space and effective solutions will be explained step by step.
4.1 Check for Signs of Disk Pressure
First, verify the signs that disk space is insufficient.
If you observe phenomena like the following, it’s time to check storage usage.
apt upgrade
- In the GUI, a warning “Insufficient disk free space” appears.
- Some apps cannot save settings or output logs.
/var
/tmp
In such situations, it’s important not only to increase free space but also to understand which areas are consuming space.
4.2 Step 1: Get an Overview of Overall Usage (df)
First, use the df -h
command to check the overall capacity status.
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 50G 48G 1.2G 98% /
/dev/sda1 512M 120M 392M 24% /boot
Use%
areas over 90% require attention.
Especially /
(root), /var
, or /home
are full, proceed to the next step.
4.3 Step 2: Investigate Which Directories Are Consuming Space (du)
Once you have identified the partition under pressure, analyze its contents with the du
command.
Example: Check Top 10 Largest Items
sudo du -hsx /* | sort -rh | head -10
Example output:
15G /var
10G /home
5.2G /usr
3.1G /snap
/var
is large, it is often due to logs or caches; if /home
is large, user data is usually the cause.
/var
Further drill down inside
sudo du -hsx /var/* | sort -rh | head -10
By traversing the hierarchy in this way, you can identify the directories consuming space.
4.4 Step 3: Delete Unnecessary Files and Caches
Once you have identified the factors compressing capacity, start cleaning up unnecessary files that can be safely deleted.
(1) Delete APT Cache
Ubuntu stores temporary files in /var/cache/apt/archives
during software updates.
Removing them can free up several gigabytes of space.
sudo apt clean
sudo apt autoremove
apt clean
apt autoremove
(2) Delete Old Log Files
/var/log
is a typical cause of storage bloat.
sudo journalctl --vacuum-time=7d
The above deletes system logs older than 7 days.
You can also manually delete unnecessary .gz
(compressed log) files.
sudo rm -f /var/log/*.gz
(3) Delete Old Versions of Snap Packages
In Ubuntu, old versions of Snap apps are retained automatically.
You can delete old snaps with the following command.
sudo snap list --all | grep disabled | awk '{print $1, $3}' |
while read snapname revision; do
sudo snap remove "$snapname" --revision="$revision"
done
Alternatively, you can use a simple “Snap Cleaner” utility.
(4) Delete Thumbnail Cache
When handling many images or videos, a large cache accumulates in ~/.cache/thumbnails
.
rm -rf ~/.cache/thumbnails/*
(5) Empty the Trash
Files deleted via the GUI may still reside in ~/.local/share/Trash/files
.
rm -rf ~/.local/share/Trash/*
4.5 Step 4: Mitigate Bloat Caused by Applications and Logs
(1) In Docker Environments
When using Docker, unnecessary images and containers consume space.
docker system df
docker system prune -a
docker system df
docker system prune -a
(2) When Frequently Using Flatpak or Snap
In environments with many installed GUI apps, remnants of applications (old versions) tend to accumulate.
Clean up with commands like flatpak uninstall --unused
.
(3) Review Log Rotation Settings
/etc/logrotate.conf
and /etc/logrotate.d/
, and
Setting appropriate log retention periods and size limits helps prevent recurrence.
4.6 Step 5: Fundamentally Resolve by Resizing or Adding Disks
If deleting files alone is insufficient, consider configuration changes such as the following.
(1) When Using LVM
In environments with LVM (Logical Volume Manager), logical volumes can be easily expanded.
sudo lvextend -L +20G /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
This allows you to increase the capacity of /
.
(2) Add a New Disk and Mount
Mount new storage at /mnt/data
, and
You can also move large directories (e.g., /var/lib/docker
or /home
) there.
(3) Utilize Cloud Storage
Moving logs and backups to services like Google Drive, Dropbox, or Nextcloud is another option.
4.7 Regular Checks to Prevent Recurrence
Low disk space is a problem that can be prevented simply by regular monitoring.
Implementing the following practices is effective.
- Periodically check and
- Create a script that automatically checks large directories.
- Settings to notify by email when the capacity threshold is exceeded ( + etc.)
Simple example:
#!/bin/bash
THRESHOLD=90
USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "Disk usage on / has exceeded ${THRESHOLD}%!" | mail -s "Disk Alert" admin@example.com
fi
4.8 Summary: Priorities for Disk Space Management
Priority | Countermeasure | Notes |
---|---|---|
★★★★★ | APT cache deletion () | High immediate effectiveness |
★★★★☆ | Log deletion () | Safe and reliable |
★★★★☆ | Delete unnecessary Snap/Flatpak versions | Enabled in desktop environment |
★★★☆☆ | Delete unnecessary Docker data | Valid for server use |
★★☆☆☆ | Disk Expansion・Add Mount | Effective as a fundamental solution |
★☆☆☆☆ | Implementation of periodic monitoring scripts | Effectiveness in long-term operation |
When disk space becomes tight on Ubuntu,
‘Identify what’s heavy → Delete from safe areas → Review configuration’
By following these three steps, most issues can be resolved.
5. Advanced Tips (Useful Techniques & Cautions)
Even if you can check and organize disk usage with the methods introduced so far, the disk can become full again as you continue operating.
Here we introduce advanced techniques to make using Ubuntu more comfortable.
5.1 Automate Regular Disk Checks
Running df
and du
manually is tedious, but you can reduce effort by using an automation script.
If you register a simple monitoring script with cron
, you can send a warning when usage exceeds a certain level.
Example: Script that sends email notification when free space drops below 10%
#!/bin/bash
THRESHOLD=90
USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "Warning: Root disk usage has reached ${USAGE}%." |
mail -s "Ubuntu Disk Usage Warning" user@example.com
fi
Save this as /usr/local/bin/check_disk.sh
and grant execute permission with chmod +x
.
Next, register the following with crontab -e
:
0 8 * * * /usr/local/bin/check_disk.sh
→ Automatic check runs every morning at 8 AM.
Convenient Points
- In addition to email, notifications can be sent using Slack Webhook and LINE Notify.
- Expandable to allow monitoring multiple mount points simultaneously.
5.2 One-liner to Find Large Files
Often, the cause of insufficient space is a specific huge file.
With the following one-liner, you can list files larger than 1GB.
sudo find / -type f -size +1G -exec ls -lh {} ; | awk '{print $9 ": " $5}'
Example output:
/var/log/syslog.1: 1.5G
/var/lib/docker/overlay2/.../diff/usr/lib/libchrome.so: 2.3G
/home/user/Downloads/video.mp4: 4.1G
In this way, you can quickly find files that should be deleted or moved.
Advanced Example: Search Only Specific Directory
sudo find /var -type f -size +500M
→ /var
is useful when searching for files larger than 500MB under it.
5.3 Alias Frequently Used Commands
Since typing long commands each time is tedious, setting up aliases is efficient.
Example: Append to ~/.bashrc
alias dfh='df -h --total'
alias duh='sudo du -hsx /* | sort -rh | head -10'
alias logs='sudo du -hs /var/log/* | sort -rh | head -10'
Apply after setting:
source ~/.bashrc
With this,
dfh
duh
logs
5.4 Continuously Observe Disk Usage Changes (Monitoring)
When operating Ubuntu over the long term, the issue of “disk space increasing without notice” can arise.
Therefore, recording disk usage changes as a history is effective.
Example: Script that records disk usage to a log file
#!/bin/bash
df -h / | awk 'NR==2 {print strftime("%Y-%m-%d %H:%M:%S"), $3, $4, $5}' >> /var/log/disk_usage.log
If you run this once a day with cron
, you can later track trends of disk usage increase.
More Advanced Methods
collectd
netdata
- Monitoring and Visualization with Prometheus + Grafana
- When operating in the cloud, it integrates with AWS CloudWatch and GCP Ops Agent.
You can perform monitoring at the operational management level without relying on GUI tools.
5.5 Beware of Permission Barriers
When checking or deleting disk usage, there are cases where accurate results cannot be obtained without root privileges.
Example:
du -sh /var
Even if you run it, a regular user will have some folders skipped with “Permission denied”,
which can result in a lower value being displayed than actual.
→ As a countermeasure, prepend sudo
or operate with administrative privileges.
5.6 Considerations for SSD/HDD Environments
SSD Environment
- To avoid unnecessary writes, run the TRIM command regularly: This allows the SSD to optimize deleted blocks.
HDD Environment
- Because log and cache fragmentation tends to progress, it is effective to restart after deleting unnecessary files.
- It is recommended to run high I/O load during low‑load periods such as midnight.
5.7 Systematize Capacity Management to Prevent Recurrence
Finally, the optimal solution for capacity management is “habitualization and systematization”.
Practical Checklist
df -h
/var/log
apt autoremove
- Delete unnecessary data of Snap and Docker regularly
- Automatic notification script has been implemented
If you perform these regularly, most capacity troubles can be prevented in advance.
Summary
In this section, we introduced advanced techniques to make disk space management on Ubuntu more efficient.
The points are the following three.
- Automation and Notifications for “Early Detection”
- Operational Efficiency Improvement Using Aliases and One-Liners
- “Safe Management Considering Permissions and Device Characteristics”
By combining these, you can elevate capacity management from a “tedious task” to a “part of system operation”.
6. FAQ (Frequently Asked Questions)
Q1. What is an easy way to check the current free space on Ubuntu?
The simplest method is to enter the following command in the terminal.
df -h
With this command, you can see at a glance the total size, used space, and free space of each drive (partition).
-h
Adding the -h option displays the sizes in a human‑readable format (GB or MB).
Q2. How can I check the size of each directory?
du
command is used.
To check the size of a specific folder, run the following.
du -sh /home
Meaning of the options:
-s
-h
If you want a more detailed view of each folder’s usage, do the following.
sudo du -h --max-depth=1 /var
Q3. df
and du
: What is the difference?
Simply put, they measure different things.
Command | Target | Main uses |
---|---|---|
df | Entire file system | Check available space |
du | File/Directory Unit | Check where the capacity is being used |
For example, to find the overall free space of /
, use df
,
to see how much space a specific folder is using, use du
.
Q4. How can I check free space using a GUI?
On Ubuntu Desktop, you can visually check it using the file manager (Nautilus) or the disk usage analyzer (Baobab).
- File Manager → Display ‘Remaining 〇〇GB’ in the bottom bar
- Baobab → Can analyze capacity breakdown with a graph
Both are beginner‑friendly and let you see results with just a click.
Q5. When “Disk is full” appears, what should I delete first?
First, delete safe caches and unnecessary files.
The recommended order is as follows.
- APT cache cleanup
sudo apt clean
- Remove unnecessary packages
sudo apt autoremove
- Log cleanup
sudo journalctl --vacuum-time=7d
- Trash and Thumbnail Cache Deletion
rm -rf ~/.cache/thumbnails/* rm -rf ~/.local/share/Trash/*
These alone can free up several gigabytes.
Q6. I’ve heard Snap apps can consume a lot of space. What should I do?
Snap keeps each version of an app, so old versions may remain.
You can remove unnecessary old revisions with the following command.
sudo snap list --all | grep disabled | awk '{print $1, $3}' |
while read snapname revision; do
sudo snap remove "$snapname" --revision="$revision"
done
Alternatively, you can manually delete them via the Snap Store GUI tool.
Q7. /var
or /home
are too large: what should I do?
/var
/var/log
/var/cache
/home
If you need to expand capacity further, you can use LVM to enlarge volumes or mount a new disk and manage it separately.
Q8. du
takes a long time. Are there ways to speed it up?
du
checks all files recursively, so it can be slow when there are many folders.
The following tricks can speed it up.
--max-depth=1
- Exclude unnecessary folders (e.g., )
ncdu
sudo apt install ncdu
sudo ncdu /
ncdu
is a lightweight, interactive tool that lets you visually inspect disk usage.
Q9. How can I prevent disk space shortages from recurring?
Implementing the following regular maintenance tasks is effective.
- Run once a week
- Once a month, check the usage of and .
df -h
- Periodically delete old data from snap () and Docker.
- If you have an SSD for automatic optimization
Automating these tasks helps prevent space shortages proactively.
Q10. What are the options for expanding capacity?
There are mainly three approaches.
- Expand volume with LVM
sudo lvextend -L +10G /dev/ubuntu-vg/ubuntu-lv sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
- Add a new disk and mount and create others, and distribute capacity management
- Leverage Cloud Storage Move large files to Google Drive and Nextcloud
If physical expansion is difficult, archiving old files is also effective.
Q11. Can I check disk usage without root privileges?
You can run the basic df -h
, but du
requires permission to view certain directories (e.g., /var/log
).
In environments without root, limit yourself to the home directory (~
).
du -sh ~/*
Q12. How can I check disk usage in a non‑GUI (server) environment?
Since the server edition of Ubuntu lacks a GUI, use the following commands as alternatives.
Purpose | Command |
---|---|
Check the total capacity | df -h |
Check directory-wise capacity | `sudo du -hsx /* |
Search for large files | sudo find / -type f -size +1G |
Visual confirmation (text UI) | sudo ncdu / |
By combining these, you can comfortably analyze disk usage without a GUI.
Q13. Is there a risk of breaking the system when checking disk usage?
Simply checking the size carries no risk.
However, be careful when deleting or resizing.
sudo rm -rf
/bin
/lib
/etc
- If you are uneasy, take a backup before executing.
Q14. Are there any tricks to save disk space?
- Shorten log retention period (Setting of )
- Delete unnecessary language packages
- Delete old kernels (may remain automatically)
Implementing these can save anywhere from a few hundred MB to several GB.
Q15. What tools do you recommend for monitoring disk usage?
Ubuntu offers the following monitoring tools.
Tool name | Features |
---|---|
ncdu | Lightweight・Fast CLI Tool |
Baobab | Check capacity visually with the GUI |
duf | df |
Netdata / Prometheus / Grafana | For server monitoring and graphing |
Summary
Through this FAQ, the key points of disk space management on Ubuntu can be summarized as follows.
- Confirmation is performed on two axes:
df
(overall) anddu
(detail) - Delete unnecessary data in a safe order (APT → log → cache)
- Automation scripts and monitoring tools are effective for preventing recurrence
If you make these practices routine, disk space problems will be virtually nonexistent.
Managing disk capacity is a modest yet essential maintenance task for keeping Ubuntu operations stable.