View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Cups

From LQWiki

Jump to: navigation, search

CUPS, the Common Unix Printing System is the most common Linux system used for turning Computer files (docs and images and everything you print) into something your printer can understand and print. For a local printer, you need to set up a cups service on your computer, for printing on a network printer, you don't.

CUPs uses IPP (internet protocol) to manage print jobs (and print queues). CUPs also supports network printers (shared printers). CUPs supports Post-Script Printer Description (PPD) supports real-world printing under Linux and Unix.

Contents

Using a local printer

If you have a local printer (so, you are on a "CUPS-Server") and want to see if your cups is well, point your browser to http://localhost:631. There you have a management interface for your printers. If you stop a printer, you will need cups administration rights. The browser will ask you for a username and a password. For that, create an user cups:

  scorpio:~ # lppasswd cups
  Enter password:
  Enter password again:

Then you can log in with "cups" as username and your password.

CUPs also supports several drivers, EPSON, DYMO, HP, and others. Please pay a visit to the CUPs website http://www.cups.org/.

Using a network printer

To use a CUPS server in the network, edit /etc/cups/client.conf. There is one line containing the string ServerName. Replace the line e.g. with ServerName myCupsServer if your CUPS server is named myCupsServer

On the server side, you need to edit /etc/cups/cupsd.conf to either allow all computers to print, or a specific computer. For each queue,and for the base CUPS system, you need to specify the permissions. Here is a working example:

Listen 127.0.0.1:631
Listen 192.168.0.9:631
Listen /var/run/cups/cups.sock

<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
# either this line
Allow From All
# or a line like this
# Allow From 192.168.0.37
</Location>

<Location /printers/ThePrinter>
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
AuthType None
# either this line 
Allow from All
# or this line
# Allow from 192.168.0.37
</Location>

In this example, we assume your cups server's IP address is 192.168.0.9 and you want to allow all your LAN's printers to print on your server. You may have to adjust 192.168.0.9, but do not adjust it to localhost - otherwise, your printer will be local-only. You will have to adjust ThePrinter to your printing queue's name, you can find it if you surf to http://localhost:631. If you are using a firewall, you will need to open holes for the CUPS communication (tcp) and data (udp) packages on both the client and server. On my system, these look like:

  iptables -A INPUT -p udp -m udp --dport 631 -j ACCEPT
  iptables -A INPUT -p tcp -m tcp --dport 631 -j ACCEPT

Of course, you can add a "-s 192.168.0.37" flag for a more restrictive hole in your firewall.

Don't forget to restart the CUPS service on your systems!

Printing

To print on a printer, local or remote, use the command lp, e.g.:

echo "this is a printout" >text.txt
lp text.txt

TroubleShooting

Pointing your browser to http://localhost:631 you might find a magnitude of error messages. Some are listed below:

  • open device failed; will retry in 30 seconds -> check the cables :)

See Also


Personal tools