Pydf an Alternative "df" Command to Check Disk Usage in Different Colours

Channel: Linux Commands Linux
Abstract: 10G). # pydf -h Filesystem Size Used Avail Use% Mounted onpydf noarch

The 「pydf」 (Python Disk File System) is an advanced command line tool and a good alternative to Linux 「df comand」. It is used to display the amount of used and available disk space on a Linux file systems, same like df command, but in different colours. The output of the pydf command can be customizable according to your needs.

Pydf Command to Check Disk Usage

This 「pydf」 command is written in python language that displays the amount of disk usage and available space on Linux mounted file system, using custom colours for different file system types.

Installing pydf

By default, pydf tool is not installed on Linux distributions, you need to install it using third party repository. So, first enable EPEL repository and afterwards enabling it, use the following 「yum command」 to install it.

On RHEL/CentOS/Fedora/Scientific Linux
# yum install pydf
Sample Output
Loaded plugins: fastestmirror, security
Determining fastest mirrors
epel/metalink								| 4.2 kB        
 * base: mirror.nbrc.ac.in
 * epel: mirrors.ispros.com.bd
 * extras: mirror.nbrc.ac.in
base                                                                   	| 3.7 kB         
epel                                                                    | 3.9 kB       
epel/primary_db                                                         | 4.2 MB        
extras                                                                  | 3.5 kB        
updates                                                                 | 3.5 kB     
updates/primary_db                                                      | 1.9 MB     
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
Is this ok [y/N]: y
Downloading Packages:
pydf-9-3.el6.noarch.rpm                                                 |  14 kB        
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pydf-9-3.el6.noarch                                          1/1 
  Verifying  : pydf-9-3.el6.noarch                                          1/1 

Installed:
 pydf.noarch 0:9-3.el6                                                                                                                                   

Complete!
On Debian/Ubuntu/Linux Mint

On Debian based distributions, the pydf tool is availabe from package manager system, you can install it using 「apt-get command」 as shown below.

$ sudo apt-get install pydf
Sample Output
[sudo] password for tecmint: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  java-wrappers
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  pydf
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
Need to get 12.1 kB of archives.
After this operation, 70.7 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu/ raring/universe pydf all 10 [12.1 kB]
Fetched 12.1 kB in 1s (6,097 B/s)
Selecting previously unselected package pydf.
(Reading database ... 175568 files and directories currently installed.)
Unpacking pydf (from .../apt/archives/pydf_10_all.deb) ...
Processing triggers for man-db ...
Setting up pydf (10) ...
How to Use pydf Command

If you run only 「pydf」 command without specifying argument, it will display just information of disk space usage along with all mounted file systems.

# pydf
Filesystem Size  Used Avail Use%                                            Mounted on
/dev/sda2   49G 3244M   44G  6.4 [###.....................................] /         
/dev/sda1  194M   43M  140M 22.4 [#########...............................] /boot     
/dev/sdb1  492G  345G  122G 70.2 [#########################...............] /data    
/dev/sda3   39G 4043M   33G 10.0 [####....................................] /home     
/dev/sda6   55G   33G   19G 60.0 [########################................] /var      
/dev/sdc1  492G  262G  205G 53.3 [#####################...................] /videos

To check which file system having 0 blocks, simple run the following command along with 「-a」 or 「–all」 argument.

# pydf -a
Filesystem  Size  Used Avail Use%                                        Mounted on             
/dev/sda2    49G 3244M   44G  6.4 [##..................................] /                       
/dev/sda1   194M   43M  140M 22.4 [########............................] /boot                   
/dev/sdb1   492G  345G  122G 70.2 [#########################...........] /data                   
devpts         0     0     0    - [....................................] /dev/pts                
tmpfs      3995M     0 3995M  0.0 [....................................] /dev/shm                
/dev/sda3    39G 4043M   33G 10.0 [####................................] /home                   
proc           0     0     0    - [....................................] /proc                   
none           0     0     0    - [....................................] /proc/sys/fs/binfmt_misc
sysfs          0     0     0    - [....................................] /sys                    
/dev/sda6    55G   33G   19G 60.0 [######################..............] /var                    
sunrpc         0     0     0    - [....................................] /var/lib/nfs/rpc_pipefs 
/dev/sdc1   492G  262G  205G 53.3 [###################.................] /videos

To see the output in human readable format, use the option 「-h」, which will print sizes (e.g., 10K, 10M, 10G).

# pydf -h
Filesystem Size  Used Avail Use%                                            Mounted on
/dev/sda2   49G 3244M   44G  6.4 [###.....................................] /         
/dev/sda1  194M   43M  140M 22.4 [#########...............................] /boot     
/dev/sdb1  492G  345G  122G 70.2 [############################............] /data
/dev/sda3   39G 4043M   33G 10.0 [####....................................] /home     
/dev/sda6   55G   33G   19G 60.0 [########################................] /var      
/dev/sdc1  492G  262G  205G 53.3 [#####################...................] /videos

To print sizes in kilobytes (e.g., 1024 block size) use option 「-k」 as shown below.

# pydf -k
Filesystem      Size      Used     Avail Use%                                        Mounted on
/dev/sda2   51606140   3321932  45662768  6.4 [##..................................] /         
/dev/sda1     198337     44371    143726 22.4 [########............................] /boot     
/dev/sdb1  516054864 362172932 127667872 70.2 [#########################...........] /data     
/dev/sda3   41284928   4140032  35047744 10.0 [####................................] /home     
/dev/sda6   57593092  34575244  20092232 60.0 [######################..............] /var      
/dev/sdc1  516054864 274980776 214860028 53.3 [###################.................] /videos

To print summary output in megabytes (e.g., 1048576 block size) use option 「-m」 as shown below.

pydf -m
Filesystem   Size   Used  Avail Use%                                           Mounted on
/dev/sda2   50397   3244  44593  6.4 [##.....................................] /         
/dev/sda1     194     43    140 22.4 [#########..............................] /boot     
/dev/sdb1  503960 353685 124675 70.2 [###########################............] /data     
/dev/sda3   40317   4043  34226 10.0 [####...................................] /home     
/dev/sda6   56243  33768  19618 60.0 [#######################................] /var      
/dev/sdc1  503960 268536 209824 53.3 [#####################..................] /videos

To print sizes in gigabytes (e.g., 1073741824), specify option 「-g」 as shown below.

# pydf -g
Filesystem   Size   Used  Avail Use%                                           Mounted on
/dev/sda2   50397   3244  44593  6.4 [##.....................................] /         
/dev/sda1     194     43    140 22.4 [#########..............................] /boot     
/dev/sdb1  503960 353685 124675 70.2 [###########################............] /data     
/dev/sda3   40317   4043  34226 10.0 [####...................................] /home     
/dev/sda6   56243  33770  19616 60.0 [#######################................] /var      
/dev/sdc1  503960 268536 209824 53.3 [#####################..................] /videos

To see the information about inodes instead of blocks, use the argument 「-i」 as given below.

# pydf -i
Filesystem Nodes  Used Avail Use%                                            Mounted on
/dev/sda2  3200k   78k 3122k  2.5 [#.......................................] /         
/dev/sda1    50k    40   50k  0.1 [........................................] /boot     
/dev/sdb1    31M  411k   31M  1.3 [#.......................................] /data     
/dev/sda3  2560k  3031 2557k  0.1 [........................................] /home     
/dev/sda6  3576k  873k 2703k 24.4 [##########..............................] /var      
/dev/sdc1    31M 2033k   29M  6.4 [###.....................................] /videos

If you want to disable colourised output, simply use the option 「–bw「.

# pydf --bw
Filesystem Size  Used Avail Use%                                            Mounted on
/dev/sda2   49G 3244M   44G  6.4 [###.....................................] /         
/dev/sda1  194M   43M  140M 22.4 [#########...............................] /boot     
/dev/sdb1  492G  345G  122G 70.2 [############################............] /data   
/dev/sda3   39G 4043M   33G 10.0 [####....................................] /home     
/dev/sda6   55G   33G   19G 60.1 [########################................] /var      
/dev/sdc1  492G  262G  205G 53.3 [#####################...................] /videos
How to Customize pydf Colours

The pydf has its own configuration file, where you can define your own custom colours to give some extra feel and look to your output.

# vi /etc/pydfrc

For more information read man pages of pydf command by hitting 「man pydf」 in a terminal.

Ref From: tecmint

Related articles