Linux Commands Examples

A great documentation place for Linux commands


Ghostscript (PostScript and PDF language interpreter and previewer)



add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2


Feel free to post other examples


no example yet ...



The gs (gswin32c, gswin32, gsos2) command invokes Ghostscript, an interpreter of Adobe Systems’ PostScript(tm) and Portable Document Format (PDF) languages. gs reads "files" in sequence and executes them as Ghostscript programs. After doing this, it reads further input from the standard input stream (normally the keyboard), interpreting each line separately and output to an output device (may be a file or an X11 window preview, see below). The interpreter exits gracefully when it encounters the "quit" command (either in a file or from the keyboard), at end-of-file, or at an interrupt signal (such as Control-C at the keyboard).




If built with X11 support, often the default device is an X11 window (previewer), else ghostscript will typically use the bbox device and print on stdout the dimension of the postscript file.




devicenames ==




gs -sDEVICE=epson






gs -sDEVICE=epson -r60x72

and the highest-density (best output quality) mode with

gs -sDEVICE=epson -r240x72.


You might want to print each page separately. To do this, send the output to a series of files ",, ..." using the "-sOutputFile=" switch with "%d" in a filename template:





You can also send output to standard output:





To select a specific paper size, use the command line switch


for instance




Most ISO and US paper sizes are recognized. See the usage documentation for a full list, or the definitions in the initialization file "".



gs -sDEVICE=bbox

prints out

%%BoundingBox: 0 25 583 732

%%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445


-- filename arg1 ...






Define a name in "systemdict" with value=null.


/name 35 def
whereas -sname=35 is equivalent to
/name (35) def


Makes Ghostscript to look first in the current directory for library files. By default, Ghostscript no longer looks in the current directory, unless, of course, the first explicitly supplied directory is "." in -I. See also the INITIALIZATION FILES section below, and bundled Use.htm for detailed discussion on search paths and how Ghostcript finds files.














String of options to be processed before the command line options


Used to specify an output device


Path names used to search for fonts


Path names for initialization files and fonts


Where temporary files are made



Startup files, utilities, and basic font definitions


More font definitions from the gsfonts package


Ghostscript demonstration files


Diverse document files

initialization files





the directories specified by the GS_LIB environment variable, if any;


the directories specified by the GS_LIB_DEFAULT macro in the Ghostscript makefile when the executable was built. When gs is built on Unix, GS_LIB_DEFAULT is usually "/usr/local/share/ghostscript/#.##:/usr/local/share/ghostscript/fonts" where "#.##" represents the Ghostscript version number. They are "/usr/share/gs-gpl/#.## on a Debian system".


safer mode

The -dSAFER option disables the "deletefile" and "renamefile" operators and prohibits opening piped commands ("%pipe%cmd"). Only "%stdout" and "%stderr" can be opened for writing. It also disables reading from files, except for "%stdin", files given as a command line argument, and files contained in paths given by LIBPATH and FONTPATH or specified by the system params /FontResourceDir and /GenericResourceDir.

This mode also sets the .LockSafetyParams parameter of the initial output device to protect against programs that attempt to write to files using the OutputFile device parameter. Since the device parameters specified on the command line, including OutputFile, are set prior to SAFER mode, use of "-sOutputFile=..." on the command line is unrestricted.

SAFER mode prevents changing the /GenericResourceDir, /FontResourceDir, /SystemParamsPassword, and /StartJobPassword.

While SAFER mode is not the default, it is the default for many wrapper scripts such as ps2pdf and may be the default in a subsequent release of Ghostscript. Thus when running programs that need to open files or set restricted parameters you should pass the -dNOSAFER command line option or its synonym -dDELAYSAFER.

When running with -dNOSAFER it is possible to perform a "save" followed by ".setsafe", execute a file or procedure in SAFER mode, and then use "restore" to return to NOSAFER mode. In order to prevent the save object from being restored by the foreign file or procedure, the ".runandhide" operator should be used to hide the save object from the restricted procedure.

special names




Disables character caching. Useful only for debugging.


Disables the "bind" operator. Useful only for debugging.








Restricts file operations the job can perform. Strongly recommended for spoolers, conversion scripts or other sensitive environments where a badly written or malicious PostScript program code must be prevented from changing important files.




Selects an alternate initial output device, as described above.




This document was last revised for Ghostscript version 9.07.

x resources


The border width in pixels (default = 1).


The name of the border color (default = black).










Ghostscript*geometry: 612x792-0+0

Ghostscript*xResolution: 72

Ghostscript*yResolution: 72

Then merge these resources into the X server’s resource database:

% xrdb -merge ~/.Xresources


See and the Usenet news group comp.lang.postscript.

see also

The various Ghostscript document files (above), especially Use.htm.


Artifex Software, Inc. are the primary maintainers of Ghostscript. Russell J. Lang, gsview at, is the author of most of the MS Windows code in Ghostscript.

How can this site be more helpful to YOU ?

give  feedback