Samstag, 15. September 2012

Color your df command

Working with the shell is good, right?!  It unleashes the power of your operating system and enables you to communicate and interact with the kernel to get informations managed by your system or to tell the system exactly what you want. One information i use quite frequent is how much disk space each file system has left using the df command.

This program shows you a summary on how much disk space you have available on each mounted file system and how much space in total can be used on each mounted file system.

The dfc (df color) command which can be downloaded from here  makes the output of df more colorful and more human readable than the old df one.

df -sW

Once you have finished downloading the the file unpack it:

tar  xvfz dfc-3.0.0.tar.gz

and change into the directory dfc-3.0.0. To install dfc

(1) first create the "build "directory beneath:

(2) Using opensuse install patterns-openSUSE-devel_C_C++ and cmake by issuing

    zypper in patterns-openSUSE-devel_C_C++ cmake

(3) Change into the build directory and issue the following command instructing cmake to create the the make files and configure the source code:


(4) Finally compile and install the program by typing:

    make && sudo make instal

(5) If you need Manpages. And i suggest you install them as root user copy the man files from the directory  you unpacked to /usr/local/share/man/man1/ and change the permissions of the dfc.1 file to 755.

    cp /home/hansel/playground/dfc3.0.0/man/dfc.1 /usr/local/man/man1/dfc.1
    chown root:root /usr/local/man/man1/dfc.1 && chmod 755 /usr/local/man/man1/dfc.1

To finally replace the dfc command with the one from the coreutils package you can use an alias. Setting:

    alias df='dfc -sW'

will give you an output like in the picture. Note that the -h option no longer gives you the so called human readable since it is human readable already but does show you the help for dfc. The nice thing is that dfc can actually determine cgroups and so called kernel pseudo file systems which are created by the kernel itself when the system boots up and does'nt show them. To show all File systems including cgroups and kernel pseudo filesystms you can use the -aoption. Also you are able to filter the file system types. For example -t ext4.vfat,ntfs only shows the disk statistics for those particular file systems.


-h  help
-s  shows a summary and sums up all values used in by the filter
-W displays the full text path of both the mount points and the device files used by the devices
-a show information about all (psuedo file systems included) file systems
-t  filter the output by file system

Also i will build a rpm which unfortunately i am not allowed to provide to due the authors strict copyright. Maybe i can post or link to the spec file.

Keine Kommentare:

Kommentar veröffentlichen

Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.