I am looking for a shell script for Ubuntu Server that lists the disk usage of directories in a decreasing order. It should not list subfolders (recursively). The behaviour should be similar to the Treesize program on Windows and should be in a human readable format. The disk space of files which are not in a folder can be grouped together as one value. For example:

4G    software
2G    terry
500M  thomas
50M   Files

Or, should I just use ncdu? https://packages.ubuntu.com/search?searchon=sourcenames&keywords=ncdu


This handy one-liner worked in root's directory on one of my servers.

root@server:~# du -h --max-depth=1 | sort -hr
29M     .
19M     ./.cache
48K     ./.ssh
24K     ./.ssh.bkup
16K     ./.local
12K     ./scripts
12K     ./.dbus
12K     ./.config
8.0K    ./.synaptic
8.0K    ./.hplip
8.0K    ./.gnupg
4.0K    ./.gvfs
4.0K    ./.gconf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.