When I use df or mount, I'm most of all interested in physical disk partitions. Nowadays the output of those commands is overwhelmed by temporary and virtual filesystems, cgroups and other things I am not interested in on a regular basis.

My physical partitions in the output always start with '/', so I tried making aliases for df and mount:

alias df1="df | egrep '^/'"
alias mount1="mount | egrep '^/'"

That works OK for mount1 (although it shows the '/' in red), but for df1 I would sometimes like to add the -h option to df and cannot do df1 -h. I would prefer not to have an alias for every option combination I might want to use. Do I really have to look into defining functions in bash (I would prefer not to)? Is there a better solution for df1?


You can solve the df1 argument issue by using the following alias:

alias df1='df --type btrfs --type ext4 --type ext3 --type ext2 --type vfat --type iso9660'

make sure to add any other type (xfs, fuseblk (for modern NTFS support, as @Pandya pointed out), etc) you're interested in. With that you can do df1 -h and get the expected result.

mount does have a -t option but you cannot specify it multiple times (only the last is taken), there I would use:

alias mount1="mount | /bin/grep -E '^/'"

I am using grep -E as egrep is deprecated and using /bin/grep makes sure you're not using --colour=auto from an alias for grep/egrep

  • df --type ntfs isn't showing 5 ntfs partition and hence skipping them in result for me – Pandya Mar 4 '16 at 9:26
  • I've to use --type fuseblk for that – Pandya Mar 4 '16 at 9:29
  • @Pandya that is what I indicated, you need to add other types you're intrested in. I haven't had ntfs partitions in my system for several years, so I'm not sure where that came from in the alias that I use. – Anthon Mar 4 '16 at 9:31
  • 1
    @Pandya looks like that --type ntfs was in my alias from the time there was minimal NTFS support (the time where you had to do a filesystem check on your NTFS partition after rebooting into Windows %-) ). Updated my answer, thanks. – Anthon Mar 4 '16 at 10:38

If switching to a different df is an option, use pydf instead, as it doesn't show filesystems having 0 blocks by default, and has a gauge, colors, and some other properties enabled by default. It works fairly well aliased to df, and the original is always available using \df anyway.

  • For me the most useful answer here. Sadly, this doesn't exist for mount. – emk2203 Nov 28 '18 at 12:57
  • A bit late, but for me pydf showed my single physical drive and 33 /dev/loop## drives when all I want is the physical drive. The accepted df answer works, but I prefer this form instead: alias dfh='df -h -x squashfs -x tmpfs' – Steve Valliere Jun 21 '19 at 11:35

You can define the function as follows:

function df1() { df "$@" | grep -E '^/'; }

Example output:

$ df1 -h
/dev/sda8        25G  8.1G   16G  35% /
/dev/sda4        25G   20G  5.8G  78% /media/pandya/Documents+Edu
/dev/sda3       9.5G  7.1G  2.0G  79% /media/pandya/Ext4
/dev/sda7        24G   17G  6.9G  71% /media/pandya/Extra+Other
/dev/sda6        26G   25G  448M  99% /media/pandya/Media+Game
/dev/sda10       15G  7.9G  7.1G  53% /media/pandya/Miscellaneous
/dev/sda5        36G   22G   14G  63% /media/pandya/Software+OS

Here $@ lets you to input your arguments! [Note that $@ should always be written within double quotation marks unless you have a concrete reason not to. -ed]


This answer attempts to address yves's following preoccupations:

I would prefer not to have an alias for every option combination (1)


although it shows the '/' in red (2)

and (3) add an important piece of info to the varying output, which is df's header line that changes according to the supplied flags.

(1) You need function, because by definition it takes arguments. And, it is very simple to define and use as you'll find out below.

(2) the red / is produced by grep --color, which is a common alias to grep itself (you can check that by running alias).


function df1 
    df $* | sed -n '1p;/^\//p;'

The newlines above are intended to improve readability, you can replace them by space.

Copy and paste this snippet directly to an interactive bash session or, even better, append it to your ~/.bashrc.

Example usage

$ df1 
Filesystem                        1K-blocks      Used Available Use% Mounted on
/dev/disk1                        487358464 316093104 171009360  65% /
/dev/disk2                           524032    302620    221412  58% /Volumes/Packer

$ df1 -hT
Filesystem                        Type   Size  Used Avail Use% Mounted on
/dev/disk1                        hfs    465G  302G  164G  65% /
/dev/disk2                        hfs    512M  296M  217M  58% /Volumes/Packer

$ df1 -hT .
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/disk1     hfs   465G  302G  164G  65% /

What it does

The function df1 calls df with whatever arguments you pass it and pipes (|) the output to sed, which is invoked with -n to suppress automatic printing of the pattern space. The rest expresses the sed "scripts", two actually:

  1. the script 1p prints the 1st line, which in our case is df's header (I use the same for ps piping),
  2. the script /^\//p matches any line starting with /, then prints it
  3. ; separates the 2 sed scripts

Reading man mount

Listing the mounts
The listing mode is maintained for backward compatibility only. For more robust and customizable output use findmnt(8), especially in your scripts.

showed me another way to get exactly the desired output.

I created a function lsmounts

lsmounts () {
  findmnt -D -t nosquashfs,notmpfs,nodevtmpfs

Explanation for the arguments:

  • -D: provide output like we know it from df
  • -t: select the types of file systems you want to see. Prepending no excludes the mentioned file systems.

So I get the desired output

SOURCE                       FSTYPE   SIZE   USED  AVAIL USE% TARGET
/dev/mapper/vgubuntu-lvroot  ext4    78,3G  42,5G  31,7G  54% /
/dev/mapper/vgubuntu-lvhome  ext4   284,5G 146,4G 124,5G  51% /home
  • 1
    This should be the top answer – rep_movsd Dec 25 '20 at 9:56

I use alias df='df -hT -xtmpfs -xdevtmpfs'.

Pretty much sucks that you have to use an alias to make GNU df actually usable on Linux these days. There should be an option to only show "real" filesystems (whatever that means).

Acually, df -hxtmpfs takes most of the crap out and remains usable without an alias. Not really worse than netstat -tulnp and such... *sigh*


alias df='df -hT --type ext4' alias lsmount=' findmnt -D -t nosquashfs,notmpfs,nodevtmpfs,nofuse.lxcfs,nobpf,nofuse '

  • This does not work for VFAT, ext2, ext3, NFS, etcetera. Also, the question is over 5 years old and has already many (better) answers. – Ljm Dullaart Apr 23 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.