Easy Steps Display Disk Space on Ubuntu 22.04 – OrcaCore
In this tutorial, we aim to guide you through the process of Display Disk Space on Ubuntu 22.04. Disk Space is a critical utility that provides users with information about the available storage on their system’s disk. This utility encompasses various sub-utilities that enable users to perform specific tasks, such as managing, checking, and freeing up disk space. Effectively monitoring and managing disk space is crucial for maintaining system performance and preventing potential storage-related issues.
Before we begin, ensure you have the necessary privileges. You must be logged in to your Ubuntu 22.04 server as a root user or a non-root user with sudo privileges. If you need assistance with this, refer to our guide on Initial Server Setup with Ubuntu 22.04.
1. Check Disk Space with df Command
The df
command is a fundamental tool for displaying the amount of disk space available on your filesystem. It provides information for each filesystem specified by its name argument. To use the df
command, simply execute the following in your terminal:
df
This will produce output similar to the following:

The output shows various columns, including Filesystem, Size, Used, Avail, Use%, and Mounted on. However, the default output can be difficult to read. To display the disk space usage in a more human-readable format, utilize the -h
option:
df -h
This will present the sizes in more understandable units like kilobytes (K), megabytes (M), gigabytes (G), and terabytes (T).
2. Check the File System Type on Ubuntu 22.04
The df
command can also display the file system type for each mounted partition. To achieve this, use the -T
option in conjunction with the df
command:
df -T
This will add a "Type" column to the output, indicating the file system type (e.g., ext4, tmpfs, squashfs).
Furthermore, you can filter the output to display information only about a specific file system type. For example, to display information about the ext4
partition, run the following command:
df -t ext4
ext4
is the default file system for many Linux distributions, including Debian and Ubuntu.
3. Check Disk Space with du command on Ubuntu 22.04
The du
(disk usage) command measures the disk space occupied by files and directories. Unlike df
, which reports on filesystem usage, du
reports on the actual space used by files.
To display the disk space usage of your current directory, use the following command:
du
This will list each file and subdirectory within the current directory, along with its disk usage in kilobytes.
To display the information in a more human-readable format, run the following command:
du -h
To display the total disk space usage of a specified directory, use the -hs
option:
du -hs /var/log
**Output**
848K /var/log
This will show the total disk space used by the /var/log
directory and its contents.
Additionally, you can combine the du
command with the sort
command to sort the files and directories by size. This is helpful for identifying the largest consumers of disk space.
du -h | sort -rn
The sort -rn
command sorts the output numerically in reverse order.
Alternative Solutions for Display Disk Space on Ubuntu 22.04
While the df
and du
commands are powerful and versatile, other tools and approaches can be used to Display Disk Space on Ubuntu 22.04. Here are two alternative solutions:
1. Using the ncdu
Command-Line Tool
ncdu
(NCurses Disk Usage) is a disk usage analyzer with an interactive, text-based interface. It allows you to navigate through your directories and see the disk space usage in a visually appealing and intuitive way.
Installation:
If ncdu
is not already installed on your system, you can install it using the following command:
sudo apt update
sudo apt install ncdu
Usage:
To analyze the disk usage of a specific directory (e.g., the root directory), run:
sudo ncdu /
This will launch the ncdu
interface, which displays a list of directories and files, sorted by size. You can navigate using the arrow keys, delete files (with caution!), and get detailed information about specific items.
ncdu
provides a more interactive and visual way to Display Disk Space on Ubuntu 22.04 than the standard df
and du
commands. It’s particularly useful for quickly identifying the largest files and directories on your system.
Why use ncdu
?
- Interactive and Visual: Easier to navigate and understand disk usage compared to plain text output.
- Fast: Efficiently scans and displays disk usage information.
- Remote Usage: Can be used over SSH connections.
- Deletion: Offers the ability to delete files and directories directly (use with caution).
2. Using a Graphical Disk Usage Analyzer (Baobab – Disk Usage Analyzer)
For users who prefer a graphical interface, Ubuntu provides a built-in Disk Usage Analyzer, also known as Baobab. This tool offers a visual representation of disk space usage, making it easy to identify large files and directories.
Usage:
You can launch the Disk Usage Analyzer by searching for "Disk Usage Analyzer" in the applications menu or by running the following command in the terminal:
baobab
When launched, Baobab prompts you to select a directory to scan. After selecting a directory, it will scan the directory and display the disk usage in a graphical format, typically as a ring chart or a treemap. This visual representation makes it easy to identify the largest consumers of disk space.
Why use Baobab?
- Visual Representation: The graphical interface provides a clear and intuitive understanding of disk usage.
- Easy to Use: Simple and straightforward interface, suitable for users of all levels.
- Directory Scanning: Allows you to scan specific directories or the entire filesystem.
- File Identification: Quickly identify large files and directories that are consuming the most space.
Conclusion
Effectively monitoring disk space is crucial for maintaining the health and performance of your Ubuntu 22.04 system. This article covered multiple methods to Display Disk Space on Ubuntu 22.04, including the fundamental df
and du
commands, as well as the interactive ncdu
and the graphical Disk Usage Analyzer (Baobab). By understanding and utilizing these tools, you can proactively manage your disk space and prevent storage-related issues. Remember to choose the tool that best suits your needs and preferences.
You may also find these articles helpful: