Cups

From LQWiki
Jump to navigation Jump to 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).

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

On the client side

To use a CUPS server in the network, create the file /etc/cups/client.conf it needs to contain only one line:

ServerName myCupsServer 

Replace myCupsServer with your print server's name.

On the server side

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 *:631
Listen /var/run/cups/cups.sock

<Location />
Order Deny,Allow
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
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 you want to allow all your LAN's printers to print on your server. 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