As you may already know, the "du" command is used to compute and summarize the file and directory space usage in Unix-like systems. If you are a heavy user of du command, you will find this guide interesting! Today, I came across a few good alternatives to du command. There could be many, but these are the ones that I am aware of at the moment. If I came across anything in future, I will add it in this list. Also, if you know any other alternatives, please let me know in the comment section below. I will review and add them in the list as well. Now let us a see some god alternatives to du command.
The Ncdu is the popular alternative to du command in the Linux community. The developer of Ncdu is not satisfied with the performance of the du command, so he ended up creating his own. Ncdu is simple, yet fast disk usage analyzer written using C programming language with an ncurses interface to find which directories or files are taking up more space either on a local or remote systems. We already have published a detailed guide about Ncdu. Check the following link if you are interested to know more about it.
2. Tin Summer
The Tin Summer is used to find the build artifacts that are taking up disk space. It is also an yet another good alternative for du command. Thanks to multi-threading, Tin-summer is significantly faster than du command when calculating the size of the big directories. Unlike Du command, it reads file sizes, not disk usage. Tin SUmmer is free, open source tool written using Rust programming language.
The developer claims Tin Summer is good alternative to du command, because,
- It is faster on larger directories compared to du command,
- It displays the disk usage results in human-readable format by default,
- It uses regex to exclude files/directories,
- Provides sorted and colorized output,
- And more.
2.1. Install Tin Summer In Linux
To install Tin Summer, open your Terminal and run the following command:
$ curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/tin-summer
Alternatively, you can install Tin Summer using Cargo package manager. Make sure you have installed Rust on your system as described in the following link.
After installing Rust, run the following command to install Tin Summer:
$ cargo install tin-summer
If either of the above mentioned methods doesn't not work, download the latest binary from the releases page and compile and install it manually.
To find the file sizes in a current working directory, use this command:
$ sn f 749 MB ./.rustup/toolchains 749 MB ./.rustup 147 MB ./.cargo/bin 147 MB ./.cargo 900 MB .
See? It displays a nicer input in human-readable format by default. You need not to use any extra flags (like -h in du command) to get this result.
To find the file sizes in a specific directory, mention the actual path like below:
$ sn f <path-to-the-directory>
We can also sort the list in the output as well. To display the sorted list of the top 5 biggest directories, run:
$ sn sort /home/sk/ -n5 749 MB /home/sk/.rustup 749 MB /home/sk/.rustup/toolchains 147 MB /home/sk/.cargo 147 MB /home/sk/.cargo/bin 2.6 MB /home/sk/mcelog 900 MB /home/sk/
For your information, the last result in the above output is the total size of the biggest directories in the given directory i.e /home/sk/. So, don't wonder why you get six results instead of 5.
To search current directory for directories with build artifacts:
$ sn ar
Tin Summer can also search for directories containing artifacts that occupy a certain size of the disk space. Say for example, to search for directories containing artifacts that occupy more than 100MB of disk space, run:
$ sn ar -t100M
Like already mentioned, Tin Summer is faster on larger directories, but it is also slower on small ones. However, the developer assures he will find a way to fix this in the future releases!
To get help, run:
$ sn --help
For more details, check the project's GitHub repository given at the end of this guide.
Dust (du+rust=dust) is more intuitive version of du utility. It will give us an instant overview of which directories are occupying the disk space without having to use head or sort commands. Like Tin Summer, it also displays the size of each directory in human-readable format by default. It is free, open source and written using Rust programming language.
3.1. Install Dust in Linux
Since the dust utility is written in Rust, It can be installed using "cargo" package manager like below.
$ cargo install du-dust
Alternatively, you can download the latest binary from the releases page and install it as shown below. As of writing this guide, the latest version was 0.3.1.
$ wget https://github.com/bootandy/dust/releases/download/v0.3.1/dust-v0.3.1-x86_64-unknown-linux-gnu.tar.gz
Extract the download file:
$ tar -xvf dust-v0.3.1-x86_64-unknown-linux-gnu.tar.gz
Finally, copy the executable file to your $PATH, for example /usr/local/bin.
$ sudo mv dust /usr/local/bin/
To find the total file sizes in the current directory and its sub-directories, run:
We can also get the full path of all directories using -p flag.
$ dust -p
To get the total size of multiple directories, just mention them with space-separated:
$ dust <dir1> <dir2>
Here are some more examples.
Show the apparent size of the files:
$ dust -s
Show particular number of directories only:
$ dust -n 10
Show 3 levels of sub-directories in the current directory:
$ dust -d 3
For help, run:
$ dust -h
For more details, refer the project's GitHub page given at the end.
Diskus It is a simple and fast alternative command line utility to
du -shcommand. The diskus utility computes the total file size of the current directory. It is a parallelized version of
du -sh or rather
du -sh --bytes command. The developer of diskus utility claims that it is about nine times faster compared to 'du -sh'. Diskus is minimal, fast and open source program written in Rust programming language.
4.1. Install diskus in Linux
The diskus utility is available in Arch Linux [Community] repository. To install it, just run:
$ sudo pacman -S diskus
On Ubuntu and its derivatives, download the latest diskus utility from the releases page and install it as shown below.
$ wget "https://github.com/sharkdp/diskus/releases/download/v0.3.1/diskus_0.3.1_amd64.deb"
$ sudo dpkg -i diskus_0.3.1_amd64.deb
Alternatively, you can install diskus using Cargo package manager. Make sure you have installed Rust 1.29 or higher on your system as described in the link given above in "Installing Tin Summer" section.
Once you have Rust on your system, run the following command to install diskus:
$ cargo install diskus
Usually, when I want to check the total disk space used by a particular directory, I use the -sh flags with du command as shown below.
$ du -sh dir
Here, -s flag indicates summary.
Using Diskus tool, I find the total size of current working directory with command:
I tested diskus to compute the total size of different directories in my Arch Linux system. The speed of computing the total size of the directory is pretty impressive! I must admit that this utility is quite faster than 'du -sh'. Please be mindful that it can find the size of the current directory only at the moment.
For getting help, run:
$ diskus -h
For more details about Diskus, refer the official GitHub page (link at the end).
Duu, short for Directory Usage Utility, is another tool to find the disk usage of given directory. It is a cross-platform, so you can use it on Windows, Mac OS and Linux operating systems. It is written in Python programming language.
5.1. Install Duu in Linux
Make sure you have installed Python3. Python3 is available in the default repositories of most Linux distributions, so the installation wouldn't be a problem.
Once Python3 is installed, download the latest Duu version from the official releases page.
$ wget https://github.com/jftuga/duu/releases/download/2.20/duu.py
To find the disk space occupied by the current working directory, simply run:
$ python3 duu.py
As you can see in the above output, Duu utility will display a nice summary of total number of files and directories and their total size in bytes, KB and MB. It will also display the total size of each item.
To display the total disk usage of a specific directory, just mention the full path like below:
$ python3 duu.py /home/sk/Downloads/
For more details, refer Duu's github page included at the end.
Duf is a command line utility to find disk usage in Linux and Unix-like systems. It displays the disk usage details in a nice tabular-column and user-friendly layout. You can even get the disk usage output in JSON format as well.
Duf is the contraction of disk usage/free. It is an open source application written in Go programming language and released under MIT license. It works under GNU/Linux, BSD and Mac OS.
To know more about Duf, refer the following guide:
Filelight is a graphical utility to visualize disk usage on your Linux system and displays the disk usage results in a colored radial layout. Filelight is one of the oldest project and it has been around for a long time. It is completely free to use and open source.
To know to how view the disk usage report with Filelight, check the following guide.
And, that's all for now. Hope this was useful. You know now seven alternatives to du command. Personally, I prefer Ncdu over all of them given in this guide. Now is your turn. Give them a try and let us know your thoughts on these tools in the comment section below.
Thank you for these utilities.
Keep your great work.
Good article. Thank you !
You may also like to use the tool ‘Top Disk Usage’ (tdu) written in Golang:
diskus is not in the AUR; it’s actually in the main arch repos. Yes, yay -S diskus will install it, but so will pacman -S diskus.
Thanks for the heads up, Kevin. I updated the guide.
Duu has a Windows build, which is available on the duu releases page, and it is multi-threaded, which I confirmed by reading through the Python source code.