Ubuntu find out which folders are taking most of hard disk space

If your hard disk is getting full on Ubuntu and you want to find out which folders are taking most of the hard disk space then you can run the following command:

du -Sh | sort -rh | head -10

The above command will list the top 10 directories consuming most of the space on your hard disk on Ubuntu.

Another command:

du -hsx -- * | sort -rh | head -10

Output

40G     azure-agent
106M    vsts-agent-linux-x64-3.214.0.tar.gz
84M     google-chrome-stable_current_amd64.deb
83M     vsts-agent-linux-x64-2.202.1.tar.gz
4.0K    tmp
4.0K    packages-microsoft-prod.deb