Ghostscript is the open source command-line access to everything postscript and PDF. Because ghostscript can do nearly everything with these files, however, it is not the easiest to use. The options can and are overwhelming to casual users who may need ghostscript for occasional and very specific purposes.

Luckily, a host of utilities have been created around ghostscript. For example:

$ ps2
ps2ascii ps2epsi ps2pdf12 ps2pdf14 ps2pk ps2ps2
ps2eps ps2pdf ps2pdf13 ps2pdfwr ps2ps ps2txt

$ pdf
pdf2djvu pdfatfi pdffonts pdfopen pdftops
pdf2dsc pdfclose pdfimages pdfseparate pdftocairo pdftosrc
pdf2ps pdfdetach pdfinfo pdfsig pdftohtml pdftotext
pdf2svg pdfetex pdflatex pdftex pdftoppm pdfunite

One utility missing from this list is the ability to make a PDF smaller in file size. Scanned full-color images can often run several megabytes in size per page.

Luckily, Alfred Klomp has created a bash script for getting smaller file sizes with PDFs via ghostscript: shrinkpdf.

To create a script/command-line application available in Ubuntu’s various flavors at any time/location from within the terminal, copy the downloaded file/script to the .local/bin/ directory in your home directory.

Then in this directory, run the command chmod 777 to make the file executable.

You now have a terminal command, shrinkpdf, available to you from any directory/folder location within the terminal.