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.

  • 5
    You can perhaps do df | grep -v "/snap" or similar, but aside from that, no,. Snaps are mounted and so will show up in things which show what is mounted. – dobey Apr 29 '18 at 2:28
  • 1
    Perhaps you could open a bug report at launchpad.net/+ubuntu/source/coreutils about installed snaps being unhelpful in the output. – dobey Apr 29 '18 at 2:41
  • 1
    You can prevent df from listing snaps with the following: df $(cut -d' ' -f3 /proc/mounts | sort -u | grep -v 'squashfs' | sed 's/^/-t /') – Martin Wimpress May 1 '18 at 14:20
  • 1
    I setup an alias: alias df='df | grep -v "/snap"' – Mike Redrobe Sep 19 '18 at 14:19
  • 3
    Instead of piping df results to grep & removing snaps, the cleaner solution is IMHO to use grep's grep -v option to exclude file systems. Snaps use squashfs. Thus you can define an alias like alias df='df -l -BM -Tx"squashfs"' to get the non-snap-list as a default. See [docs.snapcraft.io/the-snap-format/698] for a definition. – Marcus Oct 28 '18 at 10:31

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.

  • 1
    I'm generally against using alias', but I may make an exception here. Thanks! – trueCamelType Nov 1 '18 at 22:08
  • I still prefer the grep solution as this would remove all squashfs filesystems, which is not limited to snaps. – skerit Nov 25 '18 at 13:04
  • 3
    the difference is that the grep solution prevents other arguments to df from working. – tedder42 Feb 19 '19 at 23:30
  • 1
    how is this better than the proper use of df as listed in the answer, @mxmlnkn? – tedder42 Mar 24 '20 at 17:57
  • 1
    The previous function also removes lines which just happen to contain /snap. My function improves this as well as hide some other 'filesystems' I'm not interested in: function df() { command df $@ | grep -vE "(% /snap/)|(^tmpfs )|(^udev )"; } – Mark Jeronimus Apr 17 '20 at 10:33

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.


pydf | grep -v /snap

The number of way to do this is astronomical ;)

df | sed /snap/d

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.