I am writing a program that needs to print a PDF file using lp. I can print the file using a PDF viewer and the GUI, but when using lp there are issues. I'd like to see exactly what options the PDF viewer sends to CUPS so that I can use them on the lp command, but I don't see any way to do this in the CUPS interface. Is this possible?


If you know how to run your pdf viewer from the command line, for example as xpdf my.pdf, then use the following instead:

strace -f -e execve xpdf my.pdf

This will output lines like

execve("/usr/bin/lp", ["lp", "-abc", "my.pdf"], ...

which show you the commands that are being run, with the arguments shown in the array [,,,].

If you cannot run the viewer from the command line find the process id for it (with ps fax or similar), and if it is say, 2519, attach strace to it with:

strace -f -e execve -p 2519

You should get similar output. Type control-c to kill the strace.

This may not reveal the execution of lp, but you can ask strace to show more of what is being done if necessary.

  • Thanks, I'll give this a shot. Does CUPS itself not record the options provided to it? – Eric Sep 28 '18 at 21:18
  • There are several log files (see man cupsd-logs) you could look through, and spool control files in /var/spool/cups/, but I don't know anything about the binary format of these files. – meuh Sep 29 '18 at 13:49

CUPS records all options (and metadata) travelling along a job in c-files (control files) travelling along with the actual spool data d-file in /var/spool/cups/.

The control files are named cNNNNNN, where NNNNNN represents the CUPS job ID.

This bit I always knew. Yesterday I needed to have a closer look into these files, but since they are binary encoded, a simple strings-run against them didn't yield a good enough result.

First I asked a related question on StackOverflow, but later I found a tool which can dissect the c-files. It is in the CUPS source code, but doesn't build by default and hence is hardly ever seen even by the geekiest CUPS user (and also not built by Linux distribution packagers).

It's name is testipp.

How to build it and how to use it I described on StackOverflow, here:


If you have access to the CUPS error_log file (usually in /var/log/cups/), and if CUPS has LogLevel debug in its setup (in the /etc/cups/cupsd.conf file), then you can see which command line arguments where passed for each job to CUPS by grepping for the line(s) containing the string argv[5].

argv[5] contains all these parameters which CUPS had seen in the fifth argument to the command line of each filter. Preceeding these, on the same line you'll also see the respective job ID printed as [Job NNNNNN].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.