The recommended way
$ sudo apt-get update
$ sudo apt-get install ghostscript
If you need to downgrade version rather than provided by your Ubuntu-Version:
- Download "Ghostscript 9 Source" from https://www.ghostscript.com/download/gsdnld.html (direct link to gs 9.27: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs927/ghostscript-9.27.tar.gz)
- Uncompress it (i.e. tar xvf ghostscript-9.27.tar.gz)
- Go into this folder
- sudo ./configure
- sudo make
- sudo make install
- Restart Terminal
- Test with gs -v