Setup a CUPS Printer on Linux

Setting up all CUPS printers available from print.cs

17Jan2016
Note
We suggest using the Add Printers manually given that printing via cups.cs can hide some common problems, see: DirectPrintingOnLinux

Using cup.cs.uwaterloo.ca to manage printing for 13.04 and later
  • This method has the advantage of setting up all printers automatically however the disadvantage is that many common printer problems are hidden from the user
    • So we recommend you follow the section below called: see:* DirectPrintingOnLinux for each printer you want to print to
  1. For Linux versions after 13.04 the configuration file is called /etc/cups/cups-browsed.conf
  2. Edit vi /etc/cups/cups-browsed.conf and add these lines:
                Browsing On
                BrowsePoll print.cs.uwaterloo.ca
                BrowseInterval 3600
                BrowseTimeout 7200
                
  3. service cups-browsed restart

Using cup.cs.uwaterloo.ca to manage printing for 12.10 and earlier
  • This method has the advantage of setting up all printers automatically however the disadvantage is that most all printer problems are hidden from the user * So we recommend you follow the section below called: see:* DirectPrintingOnLinux for each printer you want to print to
  1. open a shell terminal
  2. sudo bash (this will give you a root shell)
  3. With your preferred editor, edit: /etc/cups/cupsd.conf and update The Browsing section
    • Find the line Browsing - change it to say On and add the lines below as follows:
                  Browsing On
                  BrowsePoll print.cs.uwaterloo.ca
                  BrowseInterval 3600
                  BrowseTimeout 7200
                  
  4. * /etc/init.d/cups restart - or - /etc/init.d/cups restart on older systems

Full CUPS package Install

Ubuntu 14.04 and 16.04

17Jan2016
  1. apt-get update
  2. apt-get install hplip cups cups-browsed cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-pk-helper cups-ppdc cups-server-common

Ubuntu 13.04

  1. apt-get update
  2. aptitude install --with-recommends cups-daemon cups-client cups-browsed cups
  3. aptitude install --with-recommends bluez-cups cups-bsd cups-common cups-driver-gutenprint cups-filters cups-pdf cups-ppdc cups-pk-helper ghostscript-cups printer-driver-gutenprint printer-driver-hpcups printer-driver-postscript-hp python-cups python-cupshelpers

Setting the default printer

      lpadmin -d lj_csgrad    (for grad student workstations)
      lpadmin -d lj_cs        (for faculty workstations)

Viewing local printers

Refreshing your printers - when nothing shows up

  • Open a terminal
  • sudo service cups-browsed restart

Adding Printers manually using direct to printer printing

17Jan2016 * See: DirectPrintingOnLinux
  1. ) This method has the advantage that the user gets direct feed back from the printer if a problem occurs
  2. ) The printer address can also be used in a web brower to determine the status of the printer itself

GNOME desktop environment

This is a manual example of manually adding a printer from a cups server
You should always try the method in the previous section first - way easier to do!
  • Open a web browser to find a list of the CUPS "printers" and "classes" you can access
    • Example "printers": open http://print.cs.uwaterloo.ca:631/printers right click on the printer name - this is actually a link that you will need, example http://print.cs.uwaterloo.ca:631/printers/lj_cs
    • Example "classes": open http://print.cs.uwaterloo.ca:631/classes right click on the class name - this is actually a link that you will need, example http://print.cs.uwaterloo.ca:631/printers/lj_csgrad
* To add the CUPS printer from Gnome
    1. System->Administration->Printing (from the top task bar on the Ubuntu/Gnome/Desktop)
    2. Add
    3. Network Printer
    4. Internet Printing Protocol
    5. Host: print.cs.uwaterloo.ca
    6. Queue: /printers/lj_cs
    7. Verify (this should work)
    8. Forward
  • Choose Driver
    1. Makes: HP (Choose Manufacturer - if not listed try Generic)
    2. Models: HP LaserJet 4100 (Choose your model)
    3. Drivers: HP LaserJet 4100 Foomatic/Postcript (Foomatic Postscript is the most common default)

Useful CUPS command line utils

  • lpstat - list printer status
    • -p list printers
    • -l -p - list printers verbose
  • lpadmin - admin/update printers
    • -d queue - set queue as default
    • -x queue - delete queue
  • /etc/init.d/cupsys restart - restart cups server on Ubuntu
  • /etc/init.d/cups restart - restart cups server on Fedora Core or Redhat Systems

Notes only for Administrators

  • Future solution. Rather than polling print.cs cups server we would prefer that the server broadcast its printers to various subnets as opposed to having clients load the server on print.cs. Unfortunately the subtleties of allowing broadcast packets through the network switches as it pertains to UDP packets has not been determined yet. Once this is done, one should edit /etc/cups/cups.d/browse.conf so that it looks like
              Browsing On
         
    and /etc/cups/cups.d/ports.conf should look like
              Listen localhost:631
              Listen /var/run/cups/cups.sock
         
    and /etc/cups/cupsd.conf file should have BrowseOrder allow,deny commented out or removed as it seems to default to deny incoming printer packets. You should also set LogLevel debug2 if there are problems in getting printing to work, otherwise, leave it at the Ubuntu default.

  • Yet another way for clients to see printers. Rather than clients polling the print server, it is possible for the server to send packets per host, i.e., a point-to-point information transmission but this would entail adding a lot of extra configuration to the server which would be difficult to maintain properly.

  • A solution that may become possible in the future that does not require a cupsd running as root. To be more precise this section explains a method that would enable allow a standard Ubuntu box to print to an RFC compliant LPD server like print.cs. Initially I (wtautz) had tried this a couple of months ago but it failed, however, for the most recent cupsys package (version 1.2.2-0ubuntu0.6.06) this method works, namely, make the lpd backend, i.e., /usr/lib/cups/backend-available/lpd setuid root, i.e., it should have permissions and ownership as follows:
         -rwsr-xr-x 1 root root 16136 2006-08-03 04:54 /usr/lib/cups/backend-available/lpd
         
    You can effect this change by running
    chmod u+s /usr/lib/cups/backend-available/lpd
    (by default the package already had ownership root as distributed by Ubuntu). However, there is a PROBLEM with this solution. If an update to the cupsys package comes along there is a possibility that this change would be undone. I (wtautz) have filed a bug report at https://launchpad.net/distros/ubuntu/+source/cupsys/+bug/47773 requesting that this ability be added to the package.

  • Adding printers via the web interface http://localhost:631. (It is possible to do remote administration but it requires some additional details that won't be covered here). NOTE. Most clients will NOT need to add printers as they will be detected automatically (if you put in BrowsePoll print.cs in /etc/cups/cupsd.conf should allow you to see the printers). However, if you want to create a printer definition locally you should use the web interface. However, Ubuntu does not want people to use the web interface to add printers. Instead, for security reasons, they prefer that you use gnome-cups-manager. However, I don't see any problem with using the web interface. To reactivate the web interface you must make it possible for cups to verify your username and password (by default this is the same as your username and password when you logged into your Ubuntu box). Hence, in order to verify your passwd, cupsd has to be able to read the shadow file. As we have the following file permissions
        -rw-r----- 1 root shadow 789 2006-08-08 12:19 /etc/shadow
        
    we see that since cupsd runs as the cupsys user, a non root user, it can only do this if the cupsys user is in the shadow group. To do this run (if you aren't root and if you are running as a user in the admin group (type groups to confirm whether you are):
    • sudo adduser cupsys shadow
    • restart the CUPS daemon:
      • sudo /etc/init.d/cupsys restart

Ubuntu Prior to 8.04 notes

Local Linux CUPS Setup

  • /etc/group - add cscf-adm to lpadmin group
  • /etc/hosts.allow - add any administrative hosts to hosts.allow
  • /etc/cups/cupsd.conf - add administrative hosts to <Location admin> section and <Location /> section

Example Changes to /etc/cups/cupsd.conf

Note you may wish to set the SystemGroup directive to your local printer admin with this directive ( lp in this example ):
SystemGroup lp
- This controls which user or users can do Administrative tasks - CUPS typically defaults to sys which is not the lp admin of most default Linux distros

  • Make sure you add your userid to the lp group if you want to log in and do admin tasks
    Warning use addgroup in Ubuntu , or groupadd -o in Fedora to add yourself - if the system is using se_linux security!

Redhat /etc/cups/cupsd.conf

<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
#CSCF - asimov MIKE GORE
Allow From 129.97.15.251
</Location>

<Location /admin>
#
# You definitely will want to limit access to the administration functions.
# The default configuration requires a local connection from a user who
# is a member of the system group to do any admin tasks.  You can change
# the group name using the SystemGroup directive.
#
#
AuthType Basic
AuthClass System

## Restrict access to local domain
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
# CSCF Mike Gore - add a remote machine for access
Allow From 129.97.15.251

#Encryption Required
</Location>

Ubuntu and Cups (Breezy Release - 5.10)

  • Reading /usr/share/doc/cupsys/ is very helpful,

  • Cups must run as root if you are trying to connect via LPD to our printers as managed by print.cs To do this the parameter RunAsUser in /etc/cups/cupsd.conf must be set to No. Restart cupsd by running /etc/init.d/cupsys restart,

  • In order to use the web interface you must authenticate with a userid that is in the group lpadmin and the Admin access portion of /etc/cups/cupsd.conf must look the same as the RedHat example above. You should now be able to login using the UNIX passwd.

  • Do not use gnome-cups-manager as it's not as flexible as the web interface.

Ubuntu and Cups (Dapper Release - 6.06)

  • CUPS web interface requires TSL support
       apt-get install libapache-mod-ssl
       apt-get install starttls
       

  • Installing cupsys will NOT install PPD files by default
       apt-get install foomatic-filters-ppds
       apt-get install gnustep-ppd hp-ppd
       

  • Cups packages needed to make basic cups services run
       apt-get install cupsys
       apt-get install cupsys-client
       apt-get install cupsys-bsd
       

  • The RunAsUser directive has been deprecated in Dapper. Initial investigations show that cupsd starts up as a non root user which means the that it no longer immediately clear how to print to print.cs via the lpd backend of cups.

CUPS queue setup example for LJP_CS - DC2320 HP4100 PS

  • open browser to http://127.0.0.1:631
  • Add New Printer
    • LJP_CS
    • DC2320
    • CS Printer in DC2320
  • Device or LJP_CS
    • IPP Host Printer
  • Device URI for LJP_CS
    • Device URI: ipp://print.cs.uwaterloo.ca/lj_cs
      or ipp://print.cs.uwaterloo.ca/printers/lj_cs
  • Model/Driver
    • HP
    • HP4300
  • Configure Printer (under main menu for printer)
    • Set Extra , General , Banner Options to suite

CUPS queue setup example for Xerox 128 in DC2560A cscflp01.cscf.uwaterloo.ca

CUPS web interface method

  • open browser to http://127.0.0.1:631
  • Add New Printer
  • Device or RICOH_DC2560A
  • Device URI for RICOH_DC2560A
    • Device URI: socket://cscflp01.cscf.uwaterloo.ca
  • Model/Driver
    • Xerox
  • Configure Printer (under main menu for printer)
    • Set Extra , General , Banner Options to suite

Testing

Setting Default Printer

Test Page

  • Open Cups Printers Menu - http://127.0.0.1:631/printers
  • Under your printer name pick the Print Test Page button
  • In a terminal window type lpq - you should see you new print queue
  • In a terminal window type echo hello world | lpr - this should print the message to the printer

Debugging

  • If the printout fails to print check the log files under /software/lpr/spool/ on print.cs or print.math - look under the directory with the same queue name as the printer

Printing queue debugging on the local machine

FYI, we been noticing cases where a print job gets stuck on Ubuntu 10.04LTS that the normal system tools can't fix - the printer may show an error state that can appear to be fixed

  1. System -> Administration -> Printing -> printer name -> Show Queue might show an empty queue when it's not.
  2. lprm will appear to work and even show an empty queue put the printer will still show an error status.
  3. /etc/init.d/cups restart won't fix it
  4. Using the Cups web interface: http://localhost:631/printers to clear the queue will appear to work and show an empty queue but not work - the printer may however show an error status.
  • This is how to fix these cases when all else fails
    • sudo bash
    • cd /var/spool/cups
    • rm * (note this will delete ALL of your spooled print jobs)
    • /etc/init.d/cups restart

Configuration of Printer and Page options

  • Open Cups Printers Menu - http://127.0.0.1:631/printers
    • Pick Configure Printer - for your printer
    • Set device options as needed - ie paper size, trays, duplex - option vary based on printer

Configure your System Default Papersize

  • Ubuntu see man papersize

Installing PPD Files

  • If you can't get a PPD file from the vendor try looking Linuxprinting.org - HERE
  • If needed you can add PPD files for a new printer to your systems PPD file directory
  • PPD should be compressed with gzip prior to placing in your systems PPD folder
  • PPD file locations for Debian
    • Files are installed in /usr/share/ppd (file need to be gziped)
    • /etc/init.d/cupsys restart after you add any PPD files
  • PPD file locations for Fedora
    • Files are installed in /usr/share/cups/model under the corresponding language directory (file need to be gziped)
    • service cups restart after you add any PPD files

HP Related CUP Drivers

PPD File Errors and Notes

  • I have noticed that hp_LaserJet_4300_Series.ppd.gz causes a trailing page with a diamond on it under Fedora Core 3

Host and User access to print.cs

  • For direct printing, don't forget to send email to accounts AT cs to authorize the host and userid for the printer you have setup! More recently (2007-) we print via cups.cs which avoids this problem.
    (note anti-spam measure on email address)

Files and Directories

  • /etc/cups
  • /var/cache/cups
    • Note: remote.cache resolves name collisions - so if you have a local printer definition and a remote one this keeps them unique.
  • /var/spool/cups

Resources

www.linuxprinting.org - Linux Printing Documents and source for Printer PPD files

Absolute Basics For Setting Up Your Printing Network

CUPS HOWTO by Brian Stults

contribs.org - various CUPS printings documents - look for CUPS

Topic revision: r64 - 2018-12-20 - CscfHelp
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback