How to get df linux command output always in GB

LinuxLinux Disk-Free

Linux Problem Overview


How to get df linux command output always in GB always? ie. I want below 34MB to be displayed in GBs

Filesystem            Size  Used Avail Use% Mounted on
/ttt/pda1              21G   20G   34M 100% /

How can this be achieved ?

Thanks in advance.

Linux Solutions


Solution 1 - Linux

You can use the -B option.

Man page of df:

> -B, --block-size=SIZE use SIZE-byte blocks

All together,

df -BG

Solution 2 - Linux

If you also want it to be a command you can reference without remembering the arguments, you could simply alias it:

alias df-gb='df -BG'

So if you type:

df-gb

into a terminal, you'll get your intended output of the disk usage in GB.

EDIT: or even use just df -h to get it in a standard, human readable format.

http://www.thegeekstuff.com/2012/05/df-examples/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAryanView Question on Stackoverflow
Solution 1 - LinuxfedorquiView Answer on Stackoverflow
Solution 2 - LinuxRadaiView Answer on Stackoverflow