Syntax of `du` command in Linux

The basic syntax of the du command is as follows:

du [options] [directory/file]

Here,

[options] = various flags that modify the behavior of the command

[directory/file] = the target directory or file for which disk usage information is desired. If no directory or file is specified, du will default to the current directory.

Example:

du /home/mandeep/test

Output:

44    /home/mandeep/test/data
2012    /home/mandeep/test/system design
24    /home/mandeep/test/table/sample_table/tree
28    /home/mandeep/test/table/sample_table
32    /home/mandeep/test/table
100104    /home/mandeep/test

du command in Linux with examples

The `du` command in Linux is a powerful utility that allows users to analyze and report on disk usage within directories and files. Whether you’re trying to identify space-hogging directories, manage disk space efficiently, or simply gain insights into storage consumption, the du command provides valuable information. In this article, we’ll explore the du command, its basic syntax, and various examples to demonstrate its functionality.

Similar Reads

Syntax of `du` command in Linux

The basic syntax of the du command is as follows:...

Options available in `du` command in Linux

The du command offers a range of options that enhance its functionality. Let’s explore some commonly used options:...

Pratical Example of du Command

Table of Content 1. `-h` option in `du` command 2. To display all files, including directories, with their sizes 3. To calculate the total size of a directory and its subdirectories 4. To obtain the disk usage summary for a directory 5. To view the timestamp of the last modification of files and directories...

1. `-h` option in `du` command

If we want to print sizes in human readable format(K, M, G), use -h option...

2. To display all files, including directories, with their sizes

Use -a option for printing all files including directories....

3. To calculate the total size of a directory and its subdirectories

Use -c option to print total size...

4. To obtain the disk usage summary for a directory

Get summary of file system using -s option...

5. To view the timestamp of the last modification of files and directories

Get the timestamp of last modified using –time option...

Frequently Asked Question

1. What is the du command in Linux, and how does it differ from the df command?...

Conclusion

In this article we have discussed the `du` command in Linux which provides us essential insights into file and directory space usage, enabling users to effectively manage their storage. We also discussed the variety of options available. Overall, we can say that mastering `du` command and its options, a user can efficiently analyze disk usage, identify storage areas, and optimize their system’s storage utilization....