
Linux Command Line
The “du” command in Linux is used to estimate the space usage of a directory or file. It is a useful tool for managing disk space and can be used to identify which files or directories are taking up the most space on a system.
When to use it
The “du” command is typically used when a user wants to check the amount of space a particular directory or file is using. It can be used to identify which files or directories are consuming the most space on a system, and can be used to make decisions about which files or directories to delete or move.
How to use it
The basic syntax of the “du” command is as follows:
du [options] [file or directory]
The most common options used with the “du” command are:
-h: Displays the sizes in “human-readable” format (i.e., in KB, MB, GB, etc.) -c: Displays the total size of all files and directories -a: Displays the size of all files, including hidden files
Examples
- To find the size of a specific directory, you can use the following command:
du -h /path/to/directory
- To find the size of all files and directories within a specific directory, you can use the following command:
du -ah /path/to/directory
- To find the total size of all files and directories within a specific directory, you can use the following command:
du -cah /path/to/directory
- To find the size of a specific file, you can use the following command:
du -h /path/to/file
In summary, the ‘du’ command is a powerful tool in Linux for managing disk space and identifying which files or directories are taking up the most space. By using different options, you can customize the output of the command to meet your needs.
See our list of 75 Linux commands you should know about.