How to display disk usage in Linux with the du command
Want to check the disk consumption on your Linux system? Here’s how to use du, a command line disk usage analyzer for Linux.
If your PC is slow or you’re having trouble installing updates and software, chances are you’re running out of disk space. The practice from The command allows Linux users to stay on top of their disk consumption and upgrade if necessary.
But how exactly do you issue this command on Linux? Let us know.
In order to use the du command, you must have the following:
A Linux based system
Linux terminal or command line
A user account with sudo or root privileges
To note: Sudo in Linux means “superuser do”. A superuser has the highest level of authorization and can perform all administrative commands.
How to use the Command
The du command displays disk usage. Using it without any options will recursively check all folders and subfolders in the current working directory. To use the basic use of the du command, just open a terminal window, type from, and hit Enter.
The output shows the disk usage and path of each directory, as well as the total disk usage of the parent directory. Besides the du command, Linux also comes with several other disk analyzers such as gdu that can display disk usage for you.
Some ordering options
The usefulness of this command can be easily extended by using various options. Here are some basic metrics you can use with:
View the output in human readable format
By default, the output generated by Linux commands is not very user-friendly, and it is difficult to determine the size of the disk by looking at the output. To make the command readable, type of -h and hit Enter.
Get Directory Size Summary
The du command generates a lot of file information that can be confusing when all you are trying to find out is the total size of your directory. To display the total size of a directory, use the -s flag with the command. the -s the flag represents To summarize.
View directory size in kilobytes (KB) or megabytes (MB)
You also have the possibility to display the size of use of the disk in KB or in MB. To achieve this, just use the -k flag for Kilobytes, and the -m flag for Megabytes.
View disk usage after system change
To view disk usage after a change on your Linux system, use the –time flag with the default command.
Monitoring Disk Usage in Linux
Du is a versatile command for Linux users because it comes with a myriad of options. If tracking disk usage is important to you, the du command should be on top of your arsenal of Linux commands.
Linux allows the superuser to grant administrative access to any user at any time. You can even change the username and other account details associated with a Linux user account.
Need to change a username and home directory in Linux? Here’s how to change user names, display names, and directory names.
About the Author