Linux – How to change the default for the “df” command in the Unix/Linux Terminal in the tcsh shell

dflinuxunix

I am in the Unix/Linux terminal right now and I'm not in any kind of editor such as vi or emacs. Now when I type in the "df" command, I get the amount of disk free space in KILOBYTES. I want to change the default so that when I type in "df" only, I get the disk free space all listed in MEGABYTES. I already know that "df -m" and "df -h" commands give the values in MEGABYTES, but I just want to strictly type in "df" so that I get all the values listed in MEGABYTES. Once again, I'm in the tcsh shell. I really would like the most basic step by step explanation to this since I have asked this several times before in the clearest way possible and still couldn't understand. I the need an extremely clear answer to this immediately since it is an emergency.

Best Answer

My df takes a -m flag:

$ df -m
Filesystem                  1M-blocks   Used Available Capacity  Mounted on
/dev/disk0s2                   380516 311007     69258    82%    /
devfs                               0      0         0   100%    /dev
map -hosts                          0      0         0   100%    /net
map auto_home                       0      0         0   100%    /home
/dev/disk0s3                    96094  42464     53630    45%    /Volumes/BOOTCAMP

You can also use df -h to get 'human-readable' values:

$ df -h
Filesystem                    Size   Used  Avail Capacity  Mounted on
/dev/disk0s2                 372Gi  304Gi   68Gi    82%    /
devfs                        124Ki  124Ki    0Bi   100%    /dev
map -hosts                     0Bi    0Bi    0Bi   100%    /net
map auto_home                  0Bi    0Bi    0Bi   100%    /home
/dev/disk0s3                  94Gi   41Gi   52Gi    45%    /Volumes/BOOTCAMP

You can also set the environment variable BLOCKSIZE to 1M, and save that in your .profile to make it the default.

$ BLOCKSIZE=1M df
Filesystem                  1M-blocks   Used Available Capacity  Mounted on
/dev/disk0s2                   380516 311008     69257    82%    /
devfs                               0      0         0   100%    /dev
map -hosts                          0      0         0   100%    /net
map auto_home                       0      0         0   100%    /home
/dev/disk0s3                    96094  42464     53630    45%    /Volumes/BOOTCAMP
Related Question