pydf – Linux tool to see colourised filesystem disk space usage

The pydf command displays the amount of used and available space on your file systems, just like df command, but in colors. The output format is completely customizable.

This is a little known tool (python script) that displays the amount of disk space available on the mounted filesystems, using different colours for different types of filesystems.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux or Unix terminal
Category Disk Management
OS compatibility BSD Linux Unix
Est. reading time 4 minutes
Advertisement

Installing the pydf on Linux

Use the apt command or apt-get command to install pydf under Debian / Ubuntu Linux. For example:
$ sudo apt-get install pydf

[sudo] password for vivek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  pydf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.8 kB of archives.
After this operation, 46.1 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 pydf all 12+nmu1 [10.8 kB]
Fetched 10.8 kB in 1s (15.5 kB/s)
Selecting previously unselected package pydf.
(Reading database ... 324744 files and directories currently installed.)
Preparing to unpack .../archives/pydf_12+nmu1_all.deb ...
Unpacking pydf (12+nmu1) ...
Setting up pydf (12+nmu1) ...

RHEL/CentOS pydf installation

RHEL / CentOS / Fedora / Rocky and Alma Linux users:
$ python3 -m venv pydf
$ source pydf/bin/activate
$ python3 -m pip install pydf

For older version of the CentOS/RHEL try the dnf command or yum command (first enable EPEL repo as described here):
# yum -y install pydf

Loaded plugins: product-id, protectbase, rhnplugin, subscription-manager
Updating certificate-based repositories.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pydf.noarch 0:9-3.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=========================================================================
 Package        Arch             Version            Repository      Size
=========================================================================
Installing:
 pydf           noarch           9-3.el6            epel            14 k
 
Transaction Summary
=========================================================================
Install       1 Package(s)
 
Total download size: 14 k
Installed size: 25 k
Downloading Packages:
pydf-9-3.el6.noarch.rpm                           |  14 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pydf-9-3.el6.noarch                                   1/1
Installed products updated.
 
Installed:
  pydf.noarch 0:9-3.el6
 
Complete!

FreeBSD install pydf

FreeBSD user can use the port as follows:
# cd /usr/ports/sysutils/pydf/ && make install clean
Or, add the package using the pkg_add/pkg command:
# pkg_add -r pydf

macOS install pydf

Try the pip command (or install homebrew on Mac and try the brew command):
$ python3 -m venv pydf
$ source pydf/bin/activate
$ python3 -m pip install pydf

How do I use pydf?

Simply type the command as follows:
$ pydf

pydf command

Fig.01: pydf command in action

To see filesystems having 0 blocks, enter:
$ pydf -a
pydf command

Fig.02: See all file systems with 0 blocks

To see human readable output i.e. show sizes in human readable format (e.g., 133K 2341M 2448G), enter:
$ pydf -h
The following option is same as -h, but use powers of 1000 not 1024:
$ pydf -H
To see information about inodes instead of blocks, enter:
$ pydf -i
Disable colourised output i.e. do not use colours:
$ pydf --bw
See quick demon of pydf command:

(Video 01: pydf command in action)

How do I customize pydf command colors?

Edit a file called /etc/pydfrc which is act as system wide main configuration file:
# vi /etc/pydfrc
You can use per-user configuration file ~/.pydfrc:
$ cp /etc/pydfrc ~/.pydfrc
$ vi ~/.pydfrc

Getting pydf outputs using specific block size

Try passing the following options
$ pydf -k
$ pydf --kilobytes
$ pydf -m
$ pydf --megabytes
$ pydf -g
$ pydf --gigabytes

Filesystem         Size Used Avail Use%                                                                                         Mounted on
/dev/vgubuntu/root  915  153   715 16.7 [##############.......................................................................] / 

Here is another outputs:

pydf - Linux and Unix tool to see colourised filesystem disk space usage

Click to enalrge

Getting help about pydf linux tool is easy

Pass the --help as follows:
$ pydf --help

Summing up

The pydf is incredible and written in Python. But, it may not be installed by default. It is a good tool for desktop users, but servers stick with the df command and du command, which are installed by default on Linux and Unix. See the pydf project home page for source code.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

16 comments… add one
  • Jay Jun 19, 2012 @ 21:22

    Sweet little command, didn’t know about this one. Thanks for the post!

  • Holger Jun 19, 2012 @ 22:33

    You should mention NCDU, which i love most!

  • Rudy Jun 20, 2012 @ 2:38

    Nice little command that does one thing and does it well. Thanks.

  • KP Jun 20, 2012 @ 4:08

    it’s good to know about different thing thanks…

  • Kenan Jun 20, 2012 @ 6:13

    Hi, the prints are diffrent like below;

    [root@linux tmp]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           28G  3.3G   23G  13% /
    /dev/sda1              99M   13M   82M  14% /boot
    tmpfs                 502M     0  502M   0% /dev/shm
    [root@linux tmp]#
    [root@linux tmp]#
    [root@linux tmp]# pydf -h
    Filesystem                      Size  Used Avail Use%                                       Mounted on
    /dev/mapper/VolGroup00-LogVol00  27G 3302M   22G 11.9 [####...............................] /
    /dev/sda1                        99M   12M   81M 12.6 [####...............................] /boot
    [root@linux tmp]#
    [root@linux tmp]#
    [root@linux tmp]# pydf -H
    Filesystem                      Size  Used Avail Use%                                       Mounted on
    /dev/mapper/VolGroup00-LogVol00  29G 3462M   24G 11.9 [####...............................] /
    /dev/sda1                       104M   13M   85M 12.6 [####...............................] /boot
    [root@linux tmp]#
    
  • Andi Jun 20, 2012 @ 7:50

    Nic little tool, thanks.
    Is there also something like “pydu” or “kdirstat” for comand line?

  • Chris F.A. Johnson Jun 20, 2012 @ 21:40

    pydf is not a standard command; not all Linux distros have it.

    It is available from http://kassiopeia.juls.savba.sk/~garabik/software/pydf/.

  • Chris F.A. Johnson Jun 21, 2012 @ 1:04

    I dislike the so-called “human-readable” format (it’s really “lossy abbreviation”), and pydf has nothing else. The best way of presenting large numbers is with thousands separators. That way the numbers themselves provide a graphic representation of their relative sizes while still being human readable. I wrote this wrapper for df:
    http://cfajohnson.com/shell/scripts/dfc-sh

  • Tim Barnett Jun 22, 2012 @ 7:03

    Tried installing pydf on FreeBSD 9 and found I had to alter the shebang line of the python script to get it to work properly. The script (/usr/local/bin/pydf) installs with

    #!/usr/bin/python

    and this needs to be changed to:

    #!/usr/local/bin/python

    Works well once adjusted.

  • mrblack Jun 27, 2012 @ 9:39

    Nice tool. Thanks.

  • Rolinh Jun 30, 2012 @ 23:08

    Very recently, I wrote a tool in C that displays space usage using graphs and colors. It has also other capabilities such as html and TeX export of the data. Have a look at the wiki page for some screenshots and information.
    Works on Linux, *BSD and OSX and is already in FreeBSD and OpenBSD ports and packaged in some Linux distro as well (Mageia, Debian, Gentoo,…).
    You might want to give it a go. 😉

  • Programster Mar 19, 2016 @ 10:20

    On CentOS 7, after running sudo yum install epel-release, I still couldn’t install pydf by running sudo yum install pydf. However I was able to install through pip by running:
    yum install -y python-pip
    sudo pip install pydf

  • Poppy Mar 13, 2021 @ 9:31

    Me too. I had no idea about such commands. thanks!

  • Georgii Sep 13, 2022 @ 13:54

    Yet another tool to have colored `df` output: https://github.com/muesli/duf

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.