sudo apt install mat2
mat2 filename.pdf # you will now end up with a file called filename.cleaned.pdf
mat2 --inplace filename.pdf # this will overwrite original file with the new one, effectively removing the original file
mat2 --show filename.pdf # this will show the metadata that will be removed, if any (similar to dry run)