How can I stop snaps from listing in df?

Ubuntu is using snaps, shown below

Core applications packaged as snaps

Shown here

enter image description here


So, my question is, that since snaps are shown using the df command, and they apparently flood df.

It's just flooding df, and makes it harder to use. Is there a way to stop it? I'm assuming since snap is planning on being used more frequently it will either no show in df, or df will become a much longer command with more pipes.


You can use df's df -x option to exclude certain file systems from the results. Since snaps use the squashfs filesystem, you can define an alias like

alias df='df -x"squashfs"'

to get the non-snap-list as a default.

BTW, see this link for a definition of the snap format.


All the snap filesystems start as /snap/ so one can use the following command:

df | grep -v /snap

The -v inverses the grep search (list things that don't match).

The advantage of this is that it will still show squashfs filesystems if you want them.

You can still use an alias if you wish:

alias df='df | grep -v /snap'

Works With Other Tools (Pydf)

Also, because this is using a pipe to grep, rather than an option of df, you can use it for other tools such as pydf.

E.g.

pydf | grep -v /snap

I find this one quite handy;

df -Thx squashfs