Introduction
In this challenge, you'll step into the shoes of a system administrator tasked with investigating disk usage on a Linux server. Your mission is to use the df and du commands to gather crucial information about the file system and directory sizes. These powerful tools will help you analyze disk space utilization and identify potential storage issues.
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
dfcommand to display the disk space usage of all mounted file systems. - Identify the file system with the highest usage percentage.
- Use the
ducommand to find the total size of the/home/labexdirectory. - Locate the largest subdirectory within
/home/labex.
Requirements
- All commands must be executed in the terminal from the
~/projectdirectory. - Use the
-hoption with bothdfandducommands to display sizes in a human-readable format. - When using
duto find the largest subdirectory, use the ░░░░░ option to limit the search to immediate subdirectories. - Store the output of the
dfcommand in a file nameddisk_usage.txtin the~/projectdirectory. - Store the size of the
/home/labexdirectory in a file namedhome_size.txtin the~/projectdirectory. - Store the name of the largest subdirectory within
/home/labexin a file namedlargest_subdir.txtin the~/projectdirectory.
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:
░░░░░░░░░░
Summary
In this challenge, you've honed your skills in using the df and du commands to analyze disk usage on a Linux system. You've learned how to display disk space information for all mounted file systems, identify high usage areas, and find the sizes of specific directories and subdirectories. These skills are crucial for system administrators in managing storage resources efficiently and proactively addressing potential disk space issues.



