Disk Space Analysis
In this step, you need to analyze disk space usage on a Linux system. You will use the df
and du
commands to identify the file system with the highest usage percentage, find the total size of a specific directory, and locate the largest subdirectory within that directory.
Tasks
- Use the
df
command to display the disk space usage of all mounted file systems.
- Identify the file system with the highest usage percentage.
- Use the
du
command to find the total size of the /home/labex
directory.
- Locate the largest subdirectory within
/home/labex
.
Requirements
- All commands must be executed in the terminal from the
~/project
directory.
- Use the
-h
option with both df
and du
commands to display sizes in a human-readable format.
- When using
du
to find the largest subdirectory, use the ░░░░░ option to limit the search to immediate subdirectories.
- Store the output of the
df
command in a file named disk_usage.txt
in the ~/project
directory.
- Store the size of the
/home/labex
directory in a file named home_size.txt
in the ~/project
directory.
- Store the name of the largest subdirectory within
/home/labex
in a file named largest_subdir.txt
in the ~/project
directory.
Example
Here's an example of what your ~/project/disk_usage.txt
file might look like:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 ░░G ░░G ░░G ░░% /
/dev/sdb1 ░░░G ░░G ░░G ░░% /data
tmpfs ░░G ░G ░░G ░% /dev/shm
The content of ~/project/home_size.txt
might be:
░░░G /home/labex
And ~/project/largest_subdir.txt
might contain:
░░░░░░░░░░