Printing : CUPS

The Common Unix Printing System: CUPS

All examples assume a printer named “printer1”.

 

Printing under CUPS: the lp command

lp myfile.txt

Specify a destination printer:

lp -d printer1 myfile.txt

Modify a print job:

lp -i <job_ID>

Print multiple copies:

lp -n 3 myfile.txt
#Prints 3 copies

Mail you a confirmation:

lp -m myfile.txt

Print landscape:

lp -o landscape myfile.txt

Print two-sided:

lp -o sides=’two-sided-short-edge’
or
lp -o sides=’two-sided-long-edge’

Set a print priority (the scale is 1-100, low to high; 50 is default):

lp -q 75 myfile.txt

Print standard output:

(date;who) | lp -d printer1

 

Setting Options

Specify a default printer for all users:

lpoptions -d printer1
#This will place information in /etc/cups/lpoptions.

Each user can set their own default printer by creating a .lpoptions file in their home directory, containing the line:

default printer1

Or add a line to their local profile (.profile or .bash_profile) file:

PRINTER=printer1
or
LPDEST=printer1

 

Viewing Printer Status

List all printers and their status:

lpstat -t #-t for “total”

Simply list all printers:

lpstat -a

Display default printer:

lpstat -d

Display jobs for one printer only:

lpstat -o printer1

Display enabled printers:

lpstat -p

Check that cupsd is running:

lpstat -r

 

Changing Printer Status

accept printer1
#This modifies the print spooler:
#”accept” means allowing print jobs
#to be sent to the spooler (not the printer).

reject printer1
#Stops the spooler from accepting
#print jobs.

/usr/bin/enable printer1
#This modifies the physical printer:
#”enable” means the printer should
#take printer jobs from the spooler.

disable printer1
#Stops the printer from receiving
#print jobs from the spooler.

About the enable command:

You must specify the full path to this command:

/usr/bin/enable

because the BASH shell also has an enable command.

disable -r “Adding paper” printer1
#-r lets you supply a reason to users

reject -r “Server shutting down” printer1
#lets you supply a reason for spooler shutdown

 

Cancelling Print Jobs

Cancel all print jobs:

cancel -a

Cancel print jobs by job number:

cancel printer1-1

Cancel all of a user’s print jobs:

cancel -u <username>

 

Controlling Access to Printers

Allow only authorized users to print to printer1:

lpadmin -u allow:root, glenn -u deny:all -d printer1

 

The CUPS Print Spool

/var/spool/cups

The CUPS Daemon Configuration File

/etc/cups/cupsd.conf

The CUPS Printer Configuration File

/etc/cups/printers.conf