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

I need to get a list of sizes in human readable du output format. How do I get the output for du command in GB under Linux or UNIX operating systems?

The du command is used to estimate file space usage. To print sizes in human readable format such as 5K, 400M, or 3G, type the following command:

ADVERTISEMENTS

du -h
du -h /tmp
du -h /home/vivek

Sample outputs:

25M	./scripts
317M	./softwares/vmware-workstation-7
4.2G	./softwares/rhel-6-workstation
4.5G	./softwares
6.5M	./pdfs/SecurityGuide
1.3M	./images-up
2.6M	./images-down
1.4G	./iso-images/OracleSolaris11Express2010_11_VM
4.9G	./iso-images

You can sort du command output using the sort command:

du -hs * | sort -h

All commands were tested using GNU/Linux and GNU coreutils v8.x only. Please refer to your local Linux / UNIX du and sort command man pages for more information.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • TryMe Jul 15, 2011 @ 9:38

    How about?

    du -k * | sort -nr | cut -f2 | xargs -d '\n' du -sh
    

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.