Reducing PDF filesize with the Command Line using Ghostscript (gs)

I use the following command line to reduce the PDF filesize:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

This command line can be used to reduce the PDF filesize on Linux.

Here are different PDFSETTINGS that can be used:

/screen
selects low-resolution output similar to the Acrobat Distiller “Screen Optimized” setting.
/ebook
selects medium-resolution output similar to the Acrobat Distiller “eBook” setting.
/printer
selects output similar to the Acrobat Distiller “Print Optimized” setting.
/prepress
selects output similar to Acrobat Distiller “Prepress Optimized” setting.
/default
selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

Checkout the resulting PDF as some settings may produce a PDF that is visually unreadable.

Reference: http://www.tjansson.dk/2012/04/compressing-pdfs-using-ghostscript-under-linux/