Compress PDFs with Ghostscript in Linux

The following two steps will help you to compress PDFs in Linux using Ghostscript:

Install Ghostscript

Update your package lists:
sudo apt-get update

Install Ghostscript:
sudo apt-get install ghostscript

Compress PDF file

Compress your PDF file using the following command:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dQUIET -sOutputFile=compressed_file.pdf original_file.pdf  

In case you want to adjust the compression level (quality) change the -dPDFSETTINGS option using one of the following:

Low quality:
/screen

Moderate quality:
/ebook

Good quality:
/printer

Best quality:
/prepress

Few stats

Original file size: ~11.5 MB
Compression at moderate quality (/ebook): ~8 MB
Compression at low quality (/screen): ~2.2 MB