Introduction
Imagine a team of space scientists exploring a new planet. Dr. Sagan, a key astrobiologist, is responsible for analyzing the planet's disk space. This is crucial for efficiently storing and managing vital research data as the team explores further. Understanding available disk space is essential for the mission's success.
Disk Space Overview
In this step, you'll learn to use the df command to get a general overview of disk space usage.
Tasks
- Use the
dfcommand to display disk space usage. - Identify the file system, size, used space, available space, usage percentage, and mount point for each disk.
Requirements
- Default working directory:
/home/labex/project - Use the
dfcommand in the terminal. - Display all disk space information.
- Save the output of the command to the file
/home/labex/project/df.txt.
Example
Running the command should produce output similar to this:
cd /home/labex/project
cat df.txt
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 20971520 128756 20842764 1% /
tmpfs 65536 0 65536 0% /dev
tmpfs 3995012 0 3995012 0% /sys/fs/cgroup
shm 65536 0 65536 0% /dev/shm
/dev/vdb 104806400 70116628 34689772 67% /etc/hosts
Filtering Disk Space Information
In this step, you'll learn to filter disk space information based on specific file systems or mount points.
Tasks
- Use the
dfcommand with the correct options to display disk space information for a specific file system or mount point. - Learn how to filter disk space information for
/home/labex.
Requirements
- Navigate to the home directory of the user
labex. - Use the
dfcommand with filtering options in the terminal. - Display disk space information for
/home/labex. - Save the output of the command to the file
/home/labex/project/df2.txt.
Example
After filtering, the output should show disk space information only for the specified file system or mount point.
cd /home/labex/project
cat df2.txt
Filesystem Size Used Avail Use% Mounted on
overlay 20G 126M 20G 1% /
Summary
In this challenge, you learned how to use the df command in Linux to report disk space usage. This skill is essential for managing disk space effectively in various environments, which helps ensure the smooth operation of data-driven tasks.



