Linux System Monitoring

Check disk usage

Price range: €13.04 through €16.40

Command:

bash
du -sh /path/to/directory

Explanation:

  • du: The command used to estimate file space usage.
  • -s: Summarizes the total disk usage of the specified directory, rather than listing the usage for each individual file and subdirectory.
  • -h: Human-readable format, which converts the output into a more readable form (e.g., KB, MB, GB).
  • /path/to/directory: Replace this with the actual path of the directory you want to check (e.g., /home/user/var/log).

Result:

This command will display the total disk usage of the specified directory in a human-readable format. For example, the output might look like this:

bash
1.2G /home/user

This indicates that the /home/user directory is using 1.2 gigabytes of disk space.


Additional Notes:

  • To view the disk usage of all subdirectories within the specified directory, you can omit the -s option:
    bash
    du -h /path/to/directory
  • To sort the output by size, you can pipe the output to the sort command:
    bash
    du -sh /path/to/directory/* | sort -h
Select options This product has multiple variants. The options may be chosen on the product page