Today I installed Ubuntu 18.04 (works on 20.04 too) on my desktop to try it out. I proceeded to run a simple df command to check which filesystems were mounted and was baffled by all of the extra devices that were mounted because of snap and systemd.
This is how my initial df output looked:
As you can see it’s a lot of information, most of which is not useful for me.
I did a quick search on how to fix it and found a bunch of bickering holy wars about snap vs. flatpak. After some good old RTFMing ( man df ) I found a solution:
Use the df command’s -x ( eXclude ) option to ignore filesystems that you don’t care to know about. The -h is used to make the size outputs “human readable” i.e. MB/GB/TB instead of just counting 1K blocks
Create an alias for df using one of the following echo commands below. The first one will append your aliases in ~/.bash_aliases ( Ubuntu’s default ~/.bashrc sources this file ) If you are using another distro e.g. Fedora you can just add the alias to the end of your home directory’s .bashrc
For Ubuntu users
echo "alias df='df -h -x squashfs -x tmpfs -x devtmpfs'" >> ~/.bash_aliases
For other *nix users
echo "alias df='df -h -x squashfs -x tmpfs -x devtmpfs'" >> ~/.bashrc
Then either reopen your terminal or manually source the new alias by running:
Now just run
df from your terminal to quickly see your usable filesystems in a friendly human readable way.