DU Command in Linux Ubuntu: DU command provides the information on Disk Usage of Files and Directories on Linux Ubuntu, and Ubuntu-based Distros. On Windows, We will get to know about the Disk Usage(in percentage) from the Task Manager. The main advantage of DU on Ubuntu is that you can check the individual files or directories disk usage thereby giving us precise data. In this article, we will check out everything about the usage of DU Command in Linux Ubuntu 18.04 LTS(Bionic Beaver), Ubuntu 19.10(Eoan Ermine), and other Ubuntu-based distros with clear examples.
- DU Command Usage Table with all flags & options
- How to use DU Command in Linux Ubuntu– Beginners Bay
- General Syntax of DU Command
- Display Disk Usage Values in Human Readable Format
- Display Disk Usage Values in KB & MB
- Display Directory Grand Total
- How to use Two Flags in DU Command
- List Disk Usage with Date and Time of Modification
- How to use Three Flags in DU Command
- Display Summarised Disk Usage of a Directory
- The help menu of DU Command
- DU Version Checkup
- Get in touch with us
Du Command Usage with flags and options:
Basic App Details & Requirements
|DU Command Flags||Usage|
|-h||Display the Disk Usage value in Human-Readable Format|
|-c||Display the Grand Total of a Directory|
|-k||Display the Disk Usage value in Kilobyte|
|-m||Display the Disk Usage value in Megabyte|
|-b||Display the Disk Usage value in Byte|
|-s||Only Provides the Summarised Disk Usage of a Directory|
|-0||Ends each output with null and no newline(Output will not be clear)|
|-a||Provide individual file’s disk usage of a directory|
|Display Disk Usage of file or folder along with its Date and Time of modification|
|Display values based on Binary Conversion(1000 and not 1024)|
|Display the Help menu of DU Command|
|DU Version check-up|
|Exclude files that match Patterns and then Display it|
|Display the files that meet the minimum threshold size that we had specified, specify the size in kilobytes|
How to Use DU Command on Linux Ubuntu 18.04 LTS/ 19.10- Clear Examples:
We have explained all the important DU Command’s usage with Examples and Images. If you find any difficulty following it up, please let us know in the comment section and we will try to solve it.
DU Command- General Syntax:
du [options] [file]
du [options] [Directory]
du [OPTION]... --files0-from=F
Example 1- (Directory’s Disk Usage Check with DU Command):
Consider the following situation. Let us create a directory(folder) named “tecrobust” on your Home directory. Now, let us check the Disk Usage of the directory “tecrobust” with the help of du command. Refer to the following image for the realtime result.
Example 2- (File’s Disk Usage Check with DU Command):
In this example, let us check the file disk usage. Instead of creating it on the Home directory, we will create it on the Desktop and name it as “tr”. Let us create a text file under the name “notes”. We are all set. It is time to check out the real-time output.
Open Terminal and change directory to Desktop using cd Desktop.
How to Display Disk Usage of files and directories in Human Readable Format(flag -h):
du -h [file]
du -h [directory]
Example- (File/Folder Disk Usage in Human Readable Format using DU Command):
I have created a directory under the name “videos” that contains a number of video files. Let us check the Disk Usage of this directory in a human-readable format.
How to Display Disk Usage Values in Bytes, KB, and MB(flag -k & flag -m):
du -k [file] (For Byte)
du -k [file] (For Kilobyte)
du -m [file] (For Megabyte)
Example- (Folder Disk Usage in KB and MB)
Let us check the disk usage of the directory “videos” that I have created on the Home Directory in Kilobyte and Megabyte.
How to Display the Total Disk Usage Value of a Directory(flag -c):
On the first method, we saw how to check the file and directory disk usage with the DU command. However, with that method, we will not get the sum total disk usage value of the specified directory rather it will just list out all the files usage value of that directory. Let us sum up totally how much a directory’s total disk usage.
du -c [folder]
Example- Grand Total Disk Usage value of a Directory:
I have a directory named snap on the Home directory that contains all the information of snap apps installed. Let us check the total disk usage of that folder.
After executing the above command on the terminal, the output as follows.
How to use two Flags with DU Command:
We are aware of using flags(options) with DU command from the above examples. Here, we will see how to use two flags in a single DU Command.
du -flag1flag2 [file]
Eg: du -ch [file]
Example- Check the Grand total(-c) of a Directory and display them in a human-readable format(-h):
Let us check the same Snap directory’s disk usage grand total and list the values in a human-readable format.
How to Display Disk Usage with Date and Time of Modification of a file or folder(flag
We will use the flag
--time to display the disk usage of a specified file or folder along with its time and date of the Modification.
du --time [file]
du --time [folder]
Example- Display Disk Usage of files/folders along with Time and Date of Modification:
We will use the same directory snap that is created on the Home directory by the snap applications.
How to use 3 different flags in DU Command(
In general, we know that a flag with one string will be accompanied by a single semicolon(-) and a flag with more than one string will be accompanied by a double semicolon(–). Here, we will see how to use both of these flags in du command.
du -flag1 --flag2 [file]
du -flag1flag2 --flag3 [file]
Example- Display a Folder’s Disk Usage along with Grand Total Usage in a Human-readable format along with its Date & Time of Creation:
The same directory “Snap” that has been created on the Home directory will be used for this explanation. As told, let us display the grand total usage of this directory in a human-readable format and also specify the date and time of the creation of the files of the snap directory.
Display the Summarized Disk Usage of a Directory(flag -s):
Sometimes, we may just need the summarized disk usage of a folder or directory. If we wish to exclude all the files of the directory’s disk usage while using the du command, then follow the below syntax.
du -s [folder]
Example- Let us summarize the Disk Usage of the Directory without listing all its file’s information:
We will use the same “Snap” Directory of the Home directory. Refer to the following example
How to get the Help menu of DU Command:
Use the following command on the terminal to get the help menu of the du command.
How to check out the DU Version:
Get in Touch with us:
The above article provides detailed information about Disk Usage Command(DU) and provides various examples with clear images and scenarios that will help beginners to understand the concepts clearly and people with experience can just pick their required command usage from the table.
If you have any queries with the above article, let us know in the comment section. For instant solutions, Kindly visit our Forum!!
For more interesting articles, Visit our Homepage