Page Body

GNU/Linux Printing

In a multi-user operating system, like a GNU/Linux distribution, printing can be a complex task.

Note: If you are not familiar with the GNU/Linux command line interface, review the Conventions page before proceeding.

The Print Queue

On a GNU/Linux system, several logged-in users may print a document at the same time. These print jobs must be ordered and printed one after the other. There is nothing wrong in principle with opening the printer like a file and writing data to it, which the Linux kernel will pass on to the actual printer.

However, this may lead to several printing processes' output becoming mixed up. Additionally, this approach would closely link application programs to the printer model in use and its interface. It is preferable to send printer output to a program that will buffer the printer data until the printer is free, rather than to the printer itself.

Additionally, this provides an opportunity to transparently translate PostScript (PS) data produced by an application to a printer-specific language. Such a program, which will buffer printer data until it can be printed and then forward it to the printer, is called a spooler.

The most common abstraction for this process is that of a queue. Print jobs are not directly sent to a printer, but to a queue, where they wait to be processed. Several queues can be assigned to a single physical printer (e.g., one queue for jobs on normal paper and another for jobs on glossy paper). Similarly, jobs sent to one queue can be passed on to a queue on another computer that organizes the actual printing.

The traditional UNIX and GNU/Linux spooler system goes back to the Berkeley Software Distribution (BSD) and is called Berkeley Line Printer Daemon (LPD). Berkeley LPD supports locally connected printers and printers connected to other hosts.

Berkeley LPD is well-suited to drive simple daisy-wheel or matrix printers (page printers, too, with some restrictions), but is not quite up to the manifold features of modern printing technology. These days, even simple printers offer simplex and duplex printing, various resolutions, color or black-and-white printing, economy modes, and many other options that, in principle, can be enabled or disabled independently of each other.

The only way of modeling this complexity in Berkeley LPD is to define different queues, which will lead to too many queues, even for a single printer. Other weaknesses of Berkeley LPD include the facts that only system administrators may configure printers, that it is tedious to identically configure all hosts on the network, and that Berkeley LPD supports neither printer classes (i.e., several printers being served from the same queue), nor accounting for print jobs.

Common UNIX Printing System (CUPS)

At present, the default printing package on almost all common GNU/Linux distributions is the Common UNIX Printing System (CUPS). This printing system offers user commands that are largely compatible to those of Berkeley LPD, but function in a different manner. The same applies to administration.

CUPS is based on the Internet Printing Protocol (IPP), which is standardized in RFC2910 and RFC2911, and intended to replace the old Berkeley LPD protocol RFC1179. Mostly, IPP provides standard operations that can be used to query a printer for its capabilities and feed to it.

This includes not only genuine printers, but also print servers driving one or more non-IPP printers. This querying includes a type of negotiation.

A print job may contain a long list of features like two-sided and toner-saving, which are matched as closely as possible. You can specify whether, if a desired feature cannot be provided, the job should be rejected or whether the printer should try to approximate what is wanted.

IPP itself makes no assumptions as to how (i.e., using what type of protocol or connection) you want to talk to a printer. However, the canonical transport protocol suggested for IPP is the Hypertext Transfer Protocol (HTTP) (see RFC2910).

This approach has several advantages:

  • HTTP is an established and well-understood protocol.
  • You get various desirable protocol features like encryption (Transport Layer Security, TLS), proxy support, and user authentication virtually for free, since suitable support exists in HTTP.
  • Users and system administrators may use standard web browsers to communicate with IPP servers (i.e., printers). A CUPS-based printing system may be administered from virtually anywhere.
  • It is easy for printer manufacturers to offer IPP support, since today's high-end printers often support a Web-based configuration interface. Now, there are many freely available HTTP servers that are suitable as the basis of an IPP implementation within a printer or print server.

IPP is developed under the auspices of the Internet Engineering Task Force (IETF) and enjoys widespread manufacturer support. CUPS is an IPP implementation for various UNIX versions (including GNU/Linux) that was developed and distributed under the GNU General Public License (GPL) by Michael Sweet via his company, Easy Software Products.

Later on, this company was acquired by Apple. Eventually, Michael left Apple and in 2020, the OpenPrinting free software organization forked CUPS, and Michael continues to work on it there.

CUPS components include:

Configuration Files
Configuration files to control the default behavior of CUPS.
Printer Drivers
Programs to help a system's Central Processing Unit (CPU) communicate with printers.
Print Scheduler
Manage print jobs, handles administrative commands, allows users to query the printer status, and manages the flow of data through CUPS components.
Print Spooler
Control access to the printer, so that one print job finishes before the next one starts. It also feeds print jobs to the printer. The print spooler can handle multiple printers.
Print Queues
Where print jobs are stacked (e.g., /var/spool/cups/) to be sent to the printer. Here, data files are prefixed with the letter d, while control files are prefixed with the letter c. Data files belong to the print queue and are automatically removed after a printer successfully handles a job.
Each printer has one or more print queues.
Job Files
Data (d) and control (c) files that are associated with each print job.
Filters
Convert job file formats to printable formats. Print data is then sent to the printer via a back end that helps locate devices connected to the system.
Back Ends
Receives printable job files from CUPS filters. Helps locate devices connected to the system.

CUPS is for UNIX and UNIX-like systems, but can be extended to work with Windows clients via Samba.

The Scheduler

At the heart of the CUPS system is an HTTP server called the scheduler. The scheduler:

  • Accepts and processes IPP requests
  • Provides online documentation
  • Allows status queries for printers and jobs
  • Keeps and updates a list of available printers

Access to the HTTP server is possible either via HTTP or via a programming interface (i.e., the CUPS API). CUPS uses the latter to provide user-level commands similar to those of BSD (e.g., lpr, lpq, lprm) and those of UNIX System V (lp, lpstat).

Also, CUPS includes various filters for different input data formats, as well as back ends to drive printers using different connections (e.g., USB, SMB, LPD). Regardless, the user just sees the IPP-capable printer implemented by CUPS.

Printing With lpr and lp

In principle, you can directly print data by sending it to the interface that the printer is connected to (depending on the permissions, you may have to have administrator privileges to do so):

# cat data.txt > '/dev/lp0'

This presupposes that no one else is simultaneously printing something else the same way, and the data must be in a format that the printer understands. For example, more expensive printers require PostScript input (if not some proprietary format) and may not be able to handle plaintext data.

This is important for troubleshooting. If you can get your printer to print something this way, then at least the hardware, cabling, and other essentials are OK, and you can search for the problem within the print system software on your GNU/Linux system.

In daily life, you should use one of the system programs that do not directly access the printer interface, but talk to the local printing system (i.e., CUPS), for printing. This way, you will achieve clean sequential job processing, and ensure data conversion into a format suitable for the printer.

The most common program for printing is lpr. You can use it to either print another program's standard output or the result of a pipeline:

pr -l 25 ex_file | lpr

The above command uses pr's -l ex_length (--length=ex_length) option to set the page length to 25 lines and prepares ex_file's content for printing.

Alternatively, you can pass lpr a list of files to be printed:

lpr ex_file...

When invoking lpr, you can pass various options:

lpr -# 3 -P 'laser' 'ex_file.txt'

The above command prints three copies of ex_file.txt to printer laser (technically, the three copies were submitted to the laser queue).

To print images in mirror image from arbitrary application commands, the -o ex_option option's mirror option can be used:

lpr -o mirror 'ex_pic.jpg'

Unless you specify otherwise, lpr submits jobs to the lp queue (some GNU/Linux distributions enable the administrator to globally change this). If you do not want to give a queue name with each job using the -P option, you can set the PRINTER environment variable to the name of the desired queue.

Besides the lpr command, which is derived from the Berkeley LPD tradition, many systems support a nearly-equivalent program called lp. This comes from UNIX System V and is familiar to many users of proprietary UNIX systems.

The following lp command is equivalent to the lpr example above:

lp -n 3 -d 'laser' 'ex_file.txt'

The CUPS version of lp allows for a few things that do not work with lpr, like modification of jobs after they have been spooled (as long as they have not yet been printed). This makes it possible to delay print jobs or freeze them for an indeterminate period of time before re-enabling them.

The CUPS version of lpr and lp support various options that influence the printed output. For example, you can request duplex (double-sided) printing:

lpr -o sides=two-sided-long-edge ex_file

You can print two reduced pages on one page:

lpr -o number-up=2 ex_file

Printing in landscape format is accomplished like so:

lpr -o landscape ex_file

The options that are permissible in each specific case depend on the abilities of the printer in question.

These are some common CUPS options:

jobsheets=<start>[,<end>]
Determine whether a banner or burst page will be printed at the beginning or end of the job. This page contains information about the submitter of the job, date, time and, for example, a classification level.
The available banner pages depend on the system in question. The standard options include none (no banner page), standard (no classification), and various pages (e.g., unclassified, confidential, topsecret).
landscape
Print in landscape format.
media=<type>
Specify the paper size and source. Valid values for the paper size include A4 or Letter.
A paper source may be given by the tray names Upper or Lower. The exact values for various printers can be derived from the corresponding PostScript Printer Description (PPD) files.
number-up={1,2,4,6,9,16}
Print 1, 2, 4, 6... pages of the job scaled down on one physical page.
number-up-layout={btlr,btrl,lrbt,lrtb,rlbt,rltb,tblr,tbrl}
The order of pages for n-up printing. For example, btlr stands for bottom to top, left to right and rltb stands for right to left, top to bottom.
outputorder={normal,reverse}
Print the job's pages in normal or reverse order.
page-border={none,single,single-thick,double,double-thick}
When printing n-up, no frame (none) or a single, single-thick, double, or double thick frame will be drawn around each scaled-down page.
page-ranges=<list>
Print only part of the job's pages. The <list> is a comma-separated sequence of page numbers or ranges of page numbers (e.g., 1-4,7,9-12).
page-set={even,odd}
Print only even-numbered (even) or odd-numbered (odd) pages.
prettyprint
(For text printing) Output a header line on each page containing the page number, the job name (usually the name of the file being printed), and the date. Also attempts syntax highlighting for C and C++ programs, and prints comment lines in italics.
sides={one-sided,two-sided-short-edge,two-sided-long-edge}
Controls two-sided printing.
two-sided-short-edge is useful for landscape pages, while two-sided-long-edge is good for portrait pages. one-sided causes one-sided printing on queues that use two-sided printing by default.

A more extensive list of options is part of the CUPS documentation. CUPS servers make this available via HTTP on port 631 on the computer with the CUPS server itself (e.g., http://localhost:631/help/options.html?TOPIC=Getting+Started). Alternatively, you can view the options list online.

lpoptions

The printing options that you can specify using the -o option with lpr and lp have certain system-wide defaults that are established when the queue is first installed. Later on, it is possible to change these defaults either as the root user (so that the options will apply to all users) or as a normal user (so that they will apply to yourself).

This does not keep users from being able to use command line options to set up different options on a job-by-job basis.

Printing options are set using the lpoptions command, which accepts the same -o options as lpr and lp. These options are applied to all queues or, if a particular queue was selected using an option, that queue only.

lpoptions enters the options in question into the ${HOME}/.lpoptions file, where lpr and lp can later pick them up. lpoptions -l displays the option names, their possible values, and the current values (labeled using an asterisk).

If you invoke lpoptions as the root user, the options apply to all users as the system-wide default. There are no printer options for the root user.

This example sets up a queue as a normal user such that normally two pages of a job will be scaled down and printed alongside each other on a landscape page:

lpoptions -d 'lp' -o number-up=2

The following command will override the above settings and print a non-scaled job without permanently changing the default settings:

lp -o number-up=1 'foo.txt'

Managing the Queue

As a normal user, you may want to figure out the state of the printer queues. The lpq command is useful for this purpose.

lpq

When called without parameters, lpq displays the contents of the default queue:

$ lpq
lp is ready and printing
Rank    Owner Job Files     Total Size
active  amnesia  333 report.ps 1112942 bytes

As with the lpr command, you can specify the name of another queue using the -P option. Otherwise, the value of the PRINTER environment variable, alternatively lp, applies.

lpq's -a option displays the jobs in all queues. Add the -l option to cause lpq to display a long listing (with more information). If +ex_interval is provided, the list is redisplayed every ex_interval seconds until the queue is empty:

lpq -al +10

lpstat

The lpstat program works differently than lpq. It uses options to determine what sort of status is to be displayed:

-a
Show the accepting state of printer queues.
By default, all printers are listed, but specific printers can be passed to the option as arguments to only show their accepting state.
-c
Show printer classes and the printers that belong to them.
By default, all printer classes are shown, but specific classes can be passed to the option as arguments to only show the printers belonging to them.
-d
Show the current default print destination.
-o
Show all print jobs.
Specific destinations can be provided to the option as arguments to only show jobs queued on those destinations.
-p
Show all printers and whether they are enabled to print.
Specific printers can be provided to the option as arguments to only show information regarding those printers.
-r
Show whether the CUPS server is running.
-s
Show a status summary, including the default destination, a list of classes and their members, and a list of printers and their associated devices.
-t
Show all status information.
-v
Show all printers and what device they are attached to.
Specific printers can be provided to the option as arguments to only show information for those printers.

Removing Print Jobs With lprm

If you change your mind after submitting a print job, you can cancel it using the lprm command:

lprm ex_job_id...

You will need the job number that lpq outputs in the Job column (e.g., 333). Since job numbers are assigned per queue, you may have to specify a queue name by means of the -P option when using lprm.

You can get rid of all of your pending print jobs using lprm -.

As a normal user, you can only cancel your own print jobs. To cancel other users' print jobs, you must assume root user privileges.

You can only use lprm to cancel jobs that have not been sent to the printer. Often, today's printers have large internal memories, which can hold one job or many jobs that are far from actually being printed, and your computer cannot usually influence these jobs any longer.

Whether a big job can be canceled that is currently half-way through being sent to the printer depends on the system.

Multipurpose Internet Mail Extensions (MIME) Types and PostScript Printer Description (PPD) Files

If a user submits a print job to CUPS, either via one of the BSD- or System V-like programs provided with CUPS, or a program that directly uses the CUPS API, the job is stored in the appropriate queue first.

In addition to the actual print data, this includes metadata like the submitter's username or the desired options for the print-out. The scheduler removes the job from the queue and first tries to convert the print data to PostScript. To do so, it consults the /usr/share/cups/mime/mime.types file in order to determine the data type in question.

/usr/share/cups/mime/mime.types contains the names of Multipurpose Internet Mail Extensions (MIME) types and, with each MIME type, a set of criteria used to recognize files of that type. For example, the rule image/gif gif string(0,GIF87a) string(0,GIF89a) identifies a file as a GIF image if its name ends in gif, or the contents start with either of the strings GIF87a or GIF89a (the exact rules for criteria are stated in detail at the beginning of the /usr/share/cups/mime/mime.types file).

Once the MIME type of the print file is known, CUPS can try to convert this to a printable format, namely application/vnd.cups-postscript. Various filter programs are provided to help with this and their use is described within the /usr/share/cups/mime/mime.convs file.

/usr/share/cups/mime/mime.convs lists various programs (at the right-hand side of a line) that are able to convert data from the type given in the leftmost column to that given in the second column. Every conversion is assigned a cost that can be converted into the CUPS PostScript format via application/postscript, which incurs a cost of 99 units. For example, if there was a direct converter, it would be preferred if its cost was less than 99.

Most formats are converted to generic PostScript first, while the pstops program is used to convert it to CUPS-specific PostScript (for your GNU/Linux distribution, pstops may be part of a package, e.g., psutils for Debian). This is an important step, since the pstops program used for this will, for example, determine and log the number of pages in the job, which is not immediately obvious from the PostScript file without executing it.

In addition, pstops provides other useful features that were not usual for UNIX printing systems in the pre-CUPS era, e.g., several pages can be scaled down and output on a single physical sheet (ps-n-up), particular pages can be selected from a larger job for actual printing (psselect) without the application having to support this feature.

The CUPS-specific PostScript file is then either directly passed on (if the job is to end up on a genuine PostScript printer) or translated to a printer-specific language, like PCL or ESC/P with GhostScript. The actual printer output (or transfer to another print server) is performed by one of the back ends in /usr/lib/cups/backend/.

The most important element of the CUPS configuration for a printer is the PostScript Printer Description (PPD) files. A printer's PPD file describes which special options (e.g., resolution, duplexing, various paper feeding methods) the printer supports, and CUPS can pass this information on to application programs that then allow the user convenient access to each printer's capabilities.

For a PostScript printer, a PPD file should be furnished (or made available on the Web) by the manufacturer. For many printers, including non-PostScript printers, PPD files can be found at https://openprinting.github.io/.

There is a reasonable chance that either CUPS or the GNU/Linux distribution that you use will contain PPD files for all but the most rare printer models. If necessary, an additional software package from your GNU/Linux distribution may need to be installed.

CUPS Installation and Configuration

CUPS is a part of all major GNU/Linux distributions or can be easily installed. CUPS allows various methods for printer configuration. The CUPS web server lets you create printer queues using a web browser, and there are also command line tools to do so.

To configure printer queues using a web browser, invoke the http://localhost:631/ URL on the CUPS machine (631 is the TCP port assigned to IPP). The CUPS interface should be displayed.

In principle, this can be accessed from any computer, but in the default configuration, IPP operations are only accepted from the same host. Via the Printers button, you can reach the printer administration page.

By selecting the Administration > Add Printer, you will reach the page to add new printers. Here, you will have to enter a name for the printer (queue) first. The other two fields (Location and Description) are not strictly required, but may help users to relate the queue name to an actual printer (i.e., they need to know where to collect their print-outs).

The next dialog is used to select a back end. This includes options such as USB or various networked options (e.g., LPD, IPP, or Windows printers via Samba). Depending on what you select here, you will have to enter a URL for the printer (e.g., lpd://lpdserver/lp or ipp://ippserver/printers/myprinter), which determines how the printer is supposed to be accessed. For printers directly connected to interfaces or USB, this is straightforward.

Finally, you need to pick a particular printer model. CUPS offers you the PPD files stored below /usr/share/cups/model/. With the GPL version, there are just a few PPD files for the most common printers. Also, you are free to download a matching PPD file from OpenPrinting and put it there.

After the final confirmation, your new printer is available below Printers and may be used. It is probably best to begin by printing a test page (Print Test Page).

/etc/cups/

The CUPS configuration directory is located at /etc/cups/. Configuration files include:

/etc/cups/classes.conf
Contains classes, i.e., a group of printers. Printing to a class queues the job to the first available printer in the class.
/etc/cups/cupsd.conf
The main configuration file. Contains the default settings.

Directives in this file include:

BrowseAddress
The broadcast address CUPS should use to account its printers.
BrowseAllow, BrowseDeny
Where incoming printer information packets will be accepted or denied from.
Browsing
Whether or not cupsd will announce its printers using broadcasts on the network.
BrowseInterval
The interval between printer announcements.
DocumentRoot
The directory where documents cupsd serves to clients are located.
Group
The cupsd group.
LogLevel
The level of detail stored in log files.
MaxClients
A limit on the number of concurrent client connections.
MaxCopies
A limit on the number of copies for a single print job.
MaxJobsPerUser
Limits the number of active print jobs per user.
ServerAdmin
The e-mail address users can use to contact the CUPS admin.
ServerName
The server name.
User
The user cupsd runs as.
/etc/cups/cupsd.conf.default
A default configuration file that you can use if you break your production cupsd.conf file.
/etc/cups/printers.conf
Configuration for each printer that you configured on the system. This is where you will find printer-specific settings.
For every printer connected to the system, a corresponding section describes the printer's status and capabilities. This file is generated after a printer is added to the system.
/etc/cups/ppd/
A directory containing the PPD files for each configured printer. Printer drivers contain descriptions for currently connected and configured printers.
/etc/cups/passwd.md5
File to store CUPS user accounts.

General configuration settings for the CUPS scheduler can be found in the /etc/cups/cupsd.conf file. This file's syntax is like that of the Apache web server's configuration file and contains the settings for access permissions and authentication.

By default, the CUPS scheduler may only be accessed from the local host. To use CUPS as a print server in a local network, this restriction must be somewhat relaxed. This can be done by means of definitions.

This example restricts access to all printers to the local system and the hosts from the 192.168.123.0/24 network:

<Location /printers>
  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1
  Allow from 192.168.123.0/24
</Location>

In the example below, access to printer new_lp only is enabled for the local system and the hosts from the 192.168.123.0/24 network, with the exception of host 192.168.123.59, which is excluded.

<Location /printers/new_lp>
  Order Allow,Deny
  Allow from 127.0.0.1
  Allow from 192.168.123.0/24
  Deny from 192.168.123.59
</Location>

Besides authentication based on IP addresses, user-based authentication via user names and passwords is also possible, as is using TLS to secure IPP operations, where the CUPS server and (possibly) the user are authenticated using X.509 certificates. In effect, this makes it possible to use CUPS as a secure, efficient fax service on the Internet.

The same printer can have several queues. CUPS allows specifying various print options, but some options require manual intervention at the printer. For example, for a simple color printer with one paper tray, it might be useful to create separate print queues for normal jobs and for jobs to be printed on high-grade glossy paper for photographs.

Normally, the printer is provided with plain paper, jobs submitted to the normal queue are immediately printed, and photo jobs collect in the photo queue. Later on, you can disable the normal queue and enable the photo queue. Once all photographs have been printed, you suspend the photo queue again, change the paper back, and re-enable the normal queue.

When CUPS printing does not work like it should, you should first inspect the CUPS log. CUPS logs details of its work to /var/log/cups/error_log (this varies between GNU/Linux distributions). The amount of log data written depends on the LogLevel directive in the /etc/cups/cupsd.conf file.

The debug2 value writes the most extensive protocol.

lpadmin

It is also possible to install new printers using the lpadmin command line tool. lpadmin is based on the eponymous System V tool, but not completely compatible. For example, you could configure a Laser-jet printer connected to a parallel interface as follows:

# lpadmin -p 'new_lp' -E -v parallel:/dev/lp0 -m laserjet.ppd

Above:

  • The -p option sets the new queue's name (new_lp).
  • The -E option enables the queue so that it will accept new jobs.
  • The -v ex_device_uri option specifies the connection details for the printer (i.e., parallel:/dev/lp0).
  • The -m ex_model option sets the printer's PPD file (which must be located within /usr/share/cups/model/).

A description and location as in the web interface can be specified using the -D ex_info and -L ex_location options, respectively.

# lpadmin -p ex_destination lets you modify existing printer configurations. # lpadmin -x ex_destination removes a printer that is no longer required.

More information on lpadmin can be found via running man 8 lpadmin.

# lppasswd -g sys -a root
Create an administrative CUPS root user.
The -g ex_group option specifies a group other than the default system group. The -a option adds a new account.
systemctl status cups.socket
Displays CUPS daemon status.
# systemctl start cups.socket
Start CUPS daemon.
# systemctl stop cups.socket
Stop CUPS daemon.
# systemctl restart cups.socket
Restart CUPS daemon.
# systemctl enable cups.socket
Enable CUPS daemon.
# systemctl disable cups.socket
Disable CUPS daemon.
xdg-open 'http://localhost:631'
Configure CUPS via a web browser interface.
lpr ex_file..., lp ex_file...
Print a file.
You can print the output of a command by piping it to these commands.
lpr -P ex_destination, lp -d ex_destination
Print a file to a specific destination.
lpr -# ex_number ex_file..., lp -n ex_number ex_file...
Print multiple copies of a file.
lpr -m ex_file..., lp -m ex_file...
Send an email to your local user account upon job completion.
lp -q ex_priority ex_file...
Set the job priority from 1 (lowest) to 100 (highest). The default priority is 50.
lpr -o sides=two-sided ex_file..., lp -o sides=2 ex_file...
Print duplex (double-sided).
lpr -o landscape ex_file..., lp -o landscape ex_file...
Print landscape.
lpoptions -d ex_destination
Set the default printer to ex_destination.
lpoptions can be used to set printer options and defaults, as well as system-wide values.
lpadmin -p ex_destination
Configure the named printer or class.
lpstat
List active jobs queued by the current user.
lpstat -p
Show a list of available printers, whether they are idle or processing, and whether they are enabled or disabled for printing.
This command tells you whether the printer queue is accepting or rejecting jobs. This refers to whether CUPS is receiving requests to print and taking responsibility for them.
CUPS can accept a job, even if printers are off/disabled (jobs are spooled in /var/spool/cups/). The jobs will print when the printer is ready.
lpstat -d
Display the name of the current default destination.
lpstat -r
Show whether the CUPS server is running.
lpstat -s
Display the status summary of the CUPS system.
This includes:
  • The default destination
  • A list of classes and their member printers
  • A list of printers and their associated devices
lpstat -t
Show all status information.
That is:
  • Whether the scheduler is running
  • The default destination
  • The list of classes and their member printers
  • The list of printers and their associated devices
  • Whether the queues are accepting requests or not
  • Whether the printers are idle or processing
  • Whether the printers are enabled or not
lpc status
Display the status of printer and class queues.
This includes:
  • The list of printers and their associated devices
  • Whether queuing is enabled
  • Whether printing is enabled
  • Print jobs
  • Whether the daemon is present or not
lpq
Display the current print queue status and jobs queued on the default destination.
The name of a specific destination can be passed to this command with the -P ex_destination option.
lpq -a
Display all print jobs on all queues for all printers.
This is a good way to view job IDs for all jobs on all printer queues.
lprm ex_job_id..., cancel ex_job_id...
Cancel a job that you own from the queue.
If no arguments are supplied, the current job on the default destination is canceled.
lprm -P ex_destination ex_job_id..., cancel ex_destination-ex_job_id...
Cancel a job that you own from a specific destination.
# lprm -, # cancel -a
Cancel all jobs in all queues from all users.
lpmove ex_job_id ex_new_destination,
lpmove ex_old_destination-ex_job_id ex_new_destination
Move a print job that you own to a new destination.
# cupsaccept ex_destination...
Tell CUPS to accept all jobs sent to the destination.
# cupsreject ex_destination
Tell CUPS to reject all jobs sent to the destination.
# cupsenable ex_destination...
Start the named printer or class.
# cupsdisable ex_destination
Stop the named printer or class.
cupsctl
Display the current CUPS configuration.
# cupsctl --remote-admin
Enable remote CUPS administration.
# cupsctl --no-remote-admin
Disable remote CUPS administration.
# cupsctl --remote-any
Enable printing from any address.
# cupsctl --no-remote-any
Disable printing from any address.
# cupsctl --user-cancel-any
Allow users to cancel jobs owned by others.
# cupsctl --no-user-cancel-any
Disallow users to cancel jobs owned by others.

PostScript (PS) and Portable Document Format (PDF) Commands

PostScript is a standard page description language. It manages the scaling of fonts and vector graphics to provide quality printouts. It is a text-based format that contains the data fed to a PostScript interpreter.

There are many GNU/Linux commands for dealing with PS and PDF files. Likely, many of these commands are not installed by default on your GNU/Linux system, but should be available in your distribution's repository.

enscript -p ex_file.ps ex_file.txt,
enscript --output=ex_file.ps ex_file.txt
Convert a text file to PostScript.
The number of columns in the output file can be specified by -ex_number (e.g., enscript -ex_number -p ex_file.ps ex_file.txt).
enscript ex_file.txt
Directly print a text file to the default printer.
pdf2ps ex_file.pdf ex_file.ps,
pdftops ex_file.pdf ex_file.ps,
convert ex_file.pdf ex_file.ps
Convert a PDF file to a PostScript file.
ps2pdf ex_file.ps ex_file.pdf,
pstopdf ex_file.ps ex_file.pdf,
convert ex_file.ps ex_file.pdf
Convert a PostScript file to a PDF file.
pdftk ex_input_1.pdf ex_input_2.pdf... cat output ex_output.pdf
Merge PDF files.
pdftk A=ex_input.pdf cat Aex_start_number-ex_end_number output ex_output.pdf
Pull specific pages out of a PDF file and into a new PDF file.
For example, the pdftk A=old.pdf cat A2-4 output new.pdf command extracts pages 2 through 4 of old.pdf and saves them to a new file, new.pdf.
pdftk A=ex_input.pdf cat A1-endright output ex_output.pdf
Rotate all pages of a file 90 degrees clockwise and save to a new file.
pdftk ex_input.pdf output ex_output.pdf user_pw PROMPT
Encrypt a PDF file.
You will be prompted to enter an encryption password on the command line.
gs \
    -dBATCH \
    -dNOPAUSE \
    -q \
    -sDEVICE=pdfwrite \
    -sOutputFile=ex_output.pdf \
    ex_input_1.pdf ex_input_2.pdf ex_input_3.pdf

Merge three PDF files.

gs \
    -sDEVICE=pdfwrite \
    -dBATCH \
    -dNOPAUSE \
    -dDOPDFMARKS=false \
    -dFirstPage=ex_first_page_number \
    -dLastPage=ex_last_page_number \
    -sOutputFile=ex_output.pdf \
    ex_input.pdf

Split page range out of a PDF file.

flpsed ex_file.pdf, flpsed ex_file.ps
Add data to a PDF or PostScript file.
This command is used for filling in forms or adding short comments into a document.
pdfinfo ex_file.pdf
Extract information about a PDF file. Specifically, print the contents of the Info dictionary (plus other useful information) from a PDF file.
pdfmod ex_file.pdf
Use a graphical interface for modifying a PDF file.

Documentation

You can find more information on the commands discussed above by examining the Linux User's Manual, either at the command line or online.

Additional information on CUPS can be found via Apple and the OpenPrinting free software organization.

Enjoyed this post?

Subscribe to the feed for the latest updates.