Skip to content
TrySitePrice

du Command Output In Human Readable Format ( GB / MB / TB )

Best/Tutorial

The du command in Linux can be used to display the size of files and directories in a human-readable format, such as GB, MB, or TB. To do this, use the -h or --human-readable option, as follows:

$ du -h /path/to/directory

This will display the size of the directory and its contents in a human-readable format, with sizes rounded to the nearest KB, MB, GB, or TB as appropriate. For example:

$ du -h /var/logrn12K	/var/log/btmprn4.0K	/var/log/lastlogrn4.0K	/var/log/wtmprn80K	/var/log

You can also specify the unit to use with the --block-size option:

$ du -h --block-size=1G /path/to/directory

This will display the sizes in units of 1 GB.

Note that the du command can take some time to run, especially when run on a large directory tree, so be patient while it completes its calculations.