This document covers the installation and maintenance of printers using CUPS and Samba. It covers local installation and networked installations and contains instructions on using shared printers from other operating systems. For information about using the lp or lpr commands for printing documents see CUPS' excellent upstream documentation.
- 1 Printing and Gentoo Linux
- 2 Installation
- 3 Configuration
- 3.1 Printing group
- 3.2 Service
- 3.3 HTTP interface
- 3.4 Files
- 3.5 Remote printer access
- 3.6 CUPS remote administration
- 3.7 Enable support for Windows PCL drivers
- 3.8 Setting up a remote printer
- 3.9 Configuring a printer
- 3.10 Using special printer drivers
- 3.11 Printing to and from Microsoft Windows
- 3.12 Printing-related applications
- 4 Removal
- 5 Troubleshooting
- 6 External resources
Printing and Gentoo Linux
Use the right tools
Linux has great support for printers; the right tool for the job is called CUPS (Common Unix Printing System). Since the beginning of the project, back in 1999, the installation and maintenance of CUPS has improved dramatically.
In this document we will cover how to use CUPS to setup a local or networked printer. It will not go in too much detail since the project has great documentation available for advanced usage.
When a user desires to install a printer on a system the first step is knowing how the printer will be attached to the system. Is it through a local port like LPT or USB, or is it networked? If it is networked, does it use the Internet Printing Protocol (IPP) or the Microsoft Windows CIFS protocol (Microsoft Windows Sharing)?
The next few sections explain what minimal kernel configuration is needed to get a printer connected in Gentoo. Of course, this depends on how the printer is going to be attached to the system, so for convenience the instructions have been separated.
Navigate to /usr/src/linux and run make menuconfig to enter the kernel configuration. If genkernel was used to configure the kernel, these steps should still be performed to make sure nothing was missed. Do not rely on genkernel to configure everything in the system automatically; printing is an area configuration settings are difficult to automatically set.
In the next configuration examples, the necessary support will be added into the kernel, not as modules. Building the kernel this way is not mandatory; if desired modular support can be easily added, just be sure to remember to load the appropriate modules!
Now go to the appropriate section to configure (or check) the kernel.
Locally attached printer (LPT)
The LPT port is generally used to identify the parallel printer port. You need to enable parallel port support first, then PC-style parallel port support (unless using a SPARC system) after which you enable parallel printer support.
Device Drivers --> <*> Parallel port support <*> PC-style hardware [*] IEEE 1284 transfer modes Character Devices --> <*> Parallel printer support
Some users might may to enable other options in the
Parallel port supportsection. Check the kernel configuration
Helpfunction for more information.
That's it! Exit the kernel configuration and rebuild the kernel.
Now continue with CUPS.
Locally attached printer (USB)
USB printing is supported by CUPS with the USB USE flag enabled. This uses the libusb library for user space USB support.
Some older software titles might still require the in-kernel USB printer support. If built as a module, this module would be called usblp:
Symbol: USB_PRINTER [=n] Type :tristate Prompt: USB Printer support Location: -> Device Drivers -> USB support (USB_SUPPORT [=y]) (1) -> Support for Host-side USB (USB [=y]) Defined at drivers/usb/class/Kconfig:21 Depends on: USB_SUPPORT [=y] && USB [=y]
However, using the in-kernel USB printer support is considered obsolete. Only pursue this when needed.
Remotely attached printer (IPP and LPD)
To be able to connect to a remotely attached printer through the Internet Printing Protocol or the Line Printer Daemon protocol the kernel needs to have networking support. Assuming the kernel has that already, continue with CUPS.
Remotely attached printer (CIFS)
The kernel must support CIFS:
File systems --> Network File Systems --> <*> CIFS support (advanced network filesystem, SMBFS successor)
After configuration for CIFS is complete, exit the kernel configuration and rebuild the kernel. Do not forget to copy the new kernel image to the /boot location (and don't forget to mount /boot if needed) and update the boot loader configuration prior to rebooting the system. Note the root commands in the LPT Printer Configuration step above for how to perform these steps.
Now continue with the next steps in the CUPS installation process.
CUPS has a few optional features that might be of interest. To enable or disable those features, use the USE flags associated with them.
USE flags for net-print/cups The Common Unix Printing System
||Add support for X11||global|
||Add support for Access Control Lists||global|
||Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)||global|
||Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces||global|
||Add support for the Java interpeter in the web server CGIs.||local|
||Add kerberos support||global|
||Do not install lp... binaries so cups and lprng can coexist.||local|
||Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip||global|
||Add support for the Python interpeter in the web server CGIs.||local|
||!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur||global|
||Add support for Secure Socket Layer connections||global|
||Build static versions of dynamic libraries as well||global|
||Enable use of systemd-specific libraries and features like socket activation or session tracking||global|
||Add threads support for various packages. Usually pthreads||global|
||Add USB support to applications that have optional USB support (e.g. cups)||global|
||Add support for the xinetd super-server||global|
||Support for DNS Service Discovery (DNS-SD)||global|
Check the current USE flag settings. To deviate from the current USE settings for CUPS alone, add the appropriate USE flags to /etc/portage/package.use file.
emerge -pv net-print/cups
[ebuild N ] net-print/cups-1.7.3 USE="X acl dbus pam ssl threads usb -debug -gnutls -java -kerberos -lprng-compat -python (-selinux) -static-libs -systemd -xinetd -zeroconf" ABI_X86="(64) (-32) (-x32)" LINGUAS="ca es fr it ja pt_BR ru" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 0 kB
When happy with the result, ask Portage to install CUPS:
emerge --ask net-print/cups
To enable SAMBA support, net-fs/samba needs to be installed with CUPS support. Update the /etc/portage/package.use file or directory to enable the
cups USE flag:
Then (re)install Samba:
emerge --ask net-fs/samba
Any user that needs to print should be added to the lp group:
gpasswd -a username lp
In order to be able to add printers and edit them via CUPS's web interface, any system user that is allowed to edit these settings should be in the lpadmin group:
gpasswd -a username lpadmin
If the printer is attached to the system locally, and the printer needs to be available every boot, the CUPS daemon will need to load automatically on start-up. Make sure the printer is attached and powered on before the CUPS daemon is started.
service cupsd start
rc-update add cupsd default
To start the CUPS daemon immediately and to make it start when the system boots, issue:
systemctl start cups.service
systemctl enable cups.service
Once the service is started, printers can be added by authenticated users. root is available by default and any member of the lpadmin group. Open up the following URL in a web browser:
The default CUPS server configuration located in /etc/cups/cupsd.conf is sufficient for most users. However, some users might need to make changes to the CUPS configuration.
In the next section covers a few changes that are often needed:
- Allow other systems to use the printer attached to this Linux workstation.
- Grant access to the CUPS administration from remote systems.
- Configure CUPS to support Windows PCL drivers. This is advised for Windows systems to be able to use a SAMBA-shared printer since most Windows drivers are PCL drivers.
- Configure this system to use a printer attached to another system (not Windows share).
Remote printer access
For other systems to use the printer through IPP, explicit access to the printer must be granted in the /etc/cups/cupsd.conf file. To share the printer using SAMBA, this change is not needed.
Open up /etc/cups/cupsd.conf in a favorite text editor and add in an
Allow line for the system(s) that should be able to reach to the printer. In the next example, access is granted to the printer from localhost and from any system whose IP address starts with
<Location /> Order allow,deny Allow localhost Allow from 192.168.0.* </Location>
This line broadcasts browsing information to the clients on the network; it will let network users know when the printer is available:
The port CUPS listens to will also need to be specified so that it will respond to printing requests from other machines on the network:
Listen *:631 #Listen localhost:631
If using CUPS 1.1 (which is now deprecated), a different syntax is required for remote printing requests:
Port 631 (Make sure the next two lines are commented out) #Listen 127.0.0.1:631 #Listen localhost:631
CUPS remote administration
If remote administration is needed, then access to the CUPS administration will need to be granted from more systems than the localhost. Edit the /etc/cups/cupsd.conf file and have explicit access granted to each system that requires access. For instance, to grant access to a system with an IP address of 192.168.0.3:
<Location /admin> (...) Encryption Required Order allow,deny Allow localhost Allow 192.168.0.3 </Location>
Do not forget to restart the CUPS daemon after making changes to /etc/cups/cupsd.conf by issuing the /etc/init.d/cupsd restart command (for OpenRC users) or systemctl restart cupsd.service (for systemd users).
Enable support for Windows PCL drivers
PCL drivers send raw data to the print server. To enable raw printing on CUPS, edit /usr/share/cups/mime/mime.types and uncomment the
application/octet-stream line if it is not already uncommented. Then edit /usr/share/cups/mime/mime.convs and do the same, if it is not already uncommented.
application/octet-stream application/vnd.cups-raw 0 -
Do not forget to restart the CUPS daemon after making these changes by running /etc/init.d/cupsd restart (for OpenRC users) or systemctl restart cupsd.service (for systemd users).
Setting up a remote printer
If the printers are attached to a remote CUPS-powered server the system can be easily configured to use the remote printer by modifying the /etc/cups/client.conf file.
Assuming the printer is attached to a system called
printserver.mydomain, open up /etc/cups/client.conf with a favorite text editor and set the
# (Substitute printserver.mydomain with your print server name) ServerName printserver.mydomain
The remote system will have a default printer setting which will be used. To change the default printer, use the lpoptions command.
First list the available printers:
hpljet5p accepting requests since Jan 01 00:00 hpdjet510 accepting requests since Jan 01 00:00
Set the HP LaserJet 5P as the default printer:
lpoptions -d hpljet5p
Configuring a printer
If the printer to be configured is remotely available through a different print server (running CUPS) then the following instructions are not needed. Instead, read Setting up a Remote Printer.
Detecting the printer
If a USB printer or parallel port printer was powered on when the Linux system booted, it might be possible to retrieve information from the kernel stating successful detection of the printer. This is merely an indication of print detection and not a requirement.
dmesg | grep -i print
parport0: Printer, Hewlett-Packard HP LaserJet 2100 Series
For a USB printer:
(...) Bus 001 Device 007: ID 03f0:1004 Hewlett-Packard DeskJet 970c/970cse
The lpinfo command can be used in order to list all connected printers:
network ipp network http network socket network https network ipps network lpd network lpd://BRW67890ABCDEF/BINARY_P1
Running lpinfo -l -v will give a more verbose output.
To list all available drivers, execute the following command:
lpinfo is not chatty and can be a little tricky to use. If any issue arises, see man lpinfo for more information.
Installing the printer
To have the printer installed on the system, fire up a browser and point it to http://localhost:631. The CUPS web interface should be displayed from which all administrative tasks can be performed.
If an HTTPS connection to CUPS is used the first time the interface is accessed it may take a very long time before the page appears. This is because the first request triggers the generation of CUPS SSL certificates which can be a time-consuming job.
Go to Administration and enter the root login and password information of the box. Then, when the administrative interface has been reached, click on Add Printer. A new screen will be displayed allowing the following information to be entered:
- The spooler name, a short but descriptive name used on the system to identify the printer. This name should not contain spaces or any special characters. For instance, for the HP LaserJet 5P could be titled
- The location, a description where the printer is physically located (for instance "bedroom", or "in the kitchen right next to the dish washer", etc.). This is to aid in maintaining several printers.
- The description, a full description of the printer. A common use is the full printer name (like "HP LaserJet 5P").
The next screen requests the device the printer listens to. The choice of several devices will be presented. The next table covers a few possible devices, but the list is not exhaustive.
|AppSocket/HP JetDirect||This special device allows for network printers to be accessible through a HP JetDirect socket. Only specific printers include support for this option.|
|Internet Printing Protocol (IPP or HTTP)||Used reach the remote printer through the IPP protocol either directly (IPP) or through HTTP.|
|LPD/LPR Host or Printer||Select this option if the printer is remote and attached to a LPD/LPR server.|
|Parallel Port #1||Select when the printer is locally attached to a parallel port (LPT). When the printer is automatically detected its name will be appended to the device.|
|USB Printer #1||Select when the printer is locally attached to a USB port. The printer name should automatically be appended to the device name.|
If installing a remote printer, the URL to the printer will be queried:
- An LPD printer server requires a
- An HP JetDirect printer requires a
- An IPP printer requires a
Next, select the printer manufacturer in the adjoining screen along with the model type and number in the subsequent screen. For many printers multiple drivers will be available. Select one now or search on OpenPrinting Printer List for a good driver. Drivers are easily able to be changed later.
Once the driver is selected, CUPS will inform that the printer has been added successfully to the system. Navigate to the printer management page on the administration interface and select Configure Printer to change the printer's settings (resolution, page format, ...).
Testing and reconfiguring the printer
To verify if the printer is working correctly, go to the printer administration page, select the printer and click on Print Test Page.
If the printer does not seem to work correctly, click on Modify Printer to reconfigure the printer. The same screens as during the first installation will appear but the defaults will now be the current configuration.
If the printer does not function, clues may be found by looking at the CUPS error log located at /var/log/cups/error_log. In the next example a permission error is discovered, probably due to a wrong Allow setting in the /etc/cups/cupsd.conf file.
(...) E [11/Jun/2005:10:23:28 +0200] [Job 102] Unable to get printer status (client-error-forbidden)!
Installing the best driver
Many printer drivers exist; to find out which one has the best performance the job, visit the OpenPrinting Printer List. Select the brand and type/model of the printer to find out what driver the site recommends. For instance, for the HP LaserJet 5P, the site recommends the
Download the PPD file from the site and place it in /usr/share/cups/model then run /etc/init.d/cupsd restart (for OpenRC users) or systemctl restart cupsd.service (for systemd users) as root. This will make the driver available through the CUPS web interface. Now reconfigure the printer as described above.
Using special printer drivers
Some printers require specific drivers or provide additional features that are not enabled through the regular configuration process (described above). This chapter will discuss a selection of printers and how they are made to work with Gentoo Linux.
The Gutenprint drivers are high-quality, open source printer drivers for various Canon, Epson, HP, Lexmark, Sony, Olympus and PCL printers supporting CUPS. They also support ghostscript, The Gimp, and other applications.
Gentoo's Portage tree contains an ebuild for the gutenprint drivers. Run emerge gutenprint to install them. Note the ebuild requests to quite a few USE flags. At minimum
ppds must enabled for gutenprint drivers to work properly.
emerge --ask net-print/gutenprint
When the emerge process has finished, the gutenprint drivers will be available through the CUPS web interface.
See HPLIP Driver.
PPA is an HP technology that focuses on sending low-level processing to the system instead of the printer which makes the printer cheaper but more resource consuming.
emerge --ask net-print/pnm2ppa
Once installed, download the PPD file for the printer OpenPrinting and put it in the /usr/share/cups/model folder. Then configure the printer using the steps explained above.
SpliX is a set of CUPS printer drivers for SPL (Samsung Printer Language) printers. While SpliX drivers are available through OpenPrinting as well, the net-print/splix package allows for quick portage-managed installation of these drivers. To install, run:
emerge --ask net-print/splix
and restart cupsd.
Brother printer drivers
Canon printer drivers
See the specific pages:
Printing to and from Microsoft Windows
Read the Samba/CUPS Guide for more detailed information on setting up CUPS with Samba.
Configuring a Windows client for IPP
Microsoft Windows supports IPP (Windows 9x and ME users need to install it separately). To install a printer on Windows that is attached to a Linux box, fire up the Add Printer wizard and select Network Printer. When asked for the URI, use the
To share the printer on the CIFS network SAMBA must be installed and configured correctly. Doing this is beyond the scope of this article, however a quick configuration of SAMBA for shared printers will be covered.
Open /etc/samba/smb.conf with a favorite text editor and add a
[printers] section to it:
[printers] comment = All printers path = /var/spool/samba browseable = no guest ok = no writable = no printable = yes public = yes printer name = hpljet5p
Navigate to the top of the smb.conf file until inside the
[global] section. Locate the
printcap name and
printing settings and set each of them to
cups (see the example below):
[global] (...) printcap name = cups printing = cups
Make sure to enable Windows PCL support in CUPS. Then, restart the smb service to have the changes take effect.
Configuring a Linux client for a Windows print server
First make sure the printer is shared on Windows systems and that net-fs/samba has been emerged with the
cups USE flag enabled (as instructed above).
To find the desired printer's URI, run the following command, substituting
server with the computer that is to probe for samba-shared printers:
smbclient -N '\\server\'
In the CUPS web interface, configure the printer as previously described. Notice CUPS has added another driver called
Windows Printer via SAMBA. Select it and use the
smb://server/printername syntax for the URI.
Any special characters in the above URI need to be appropriately quoted. For example:
smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6
This result string can be obtained by running the following command:
python2 -c 'import urllib; print "smb://" + urllib.quote("BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6")'
Many tools exist to help configure a printer, use additional printing filters, add features to printing capabilities, etc. This chapter will list a few of them. Be aware the list is not exhaustive and not meant to discuss each tool in great detail.
Gtk-LP - A GTK-powered printer configuration tool
With net-print/gtklp, the installation, modification and configuration of a printer can be performed from a stand-alone GTK+ application. It uses CUPS and provides all standard CUPS capabilities. It is definitely worth checking out if the CUPS Web interface is disliked or if a stand-alone application for day-to-day printing routines is desired.
emerge --ask net-print/gtklp
Printer configuration tool for KDE 4
KDE 4 also has a printer config tool called kde-apps/print-manager. It works with CUPS and provides a user-friendly interface to configure printers. Install it as follows:
emerge --ask kde-apps/print-manager
Packages that are currently installed with the
cups USE flag must be modified. Search through /etc/portage/package.use to see if any packages explicitly have the
cups flag and remove it.
Next, it may be necessary to remove the
cups value from /etc/portage/make.conf's USE variable if it had been previously set.
emerge --ask --depclean net-print/cups
Finally, clean the system of any packages that are no longer needed as a result of CUPS being removed.
emerge --ask --depclean
Error: Unable to convert file 0 to printable format
While having printing troubles and /var/log/cups/error_log shows this message:
Unable to convert file 0 to printable format
Re-emerge app-text/ghostscript-gpl with the
cups USE flag. You can either add
cups to the system USE flags in /etc/portage/make.conf or enable it only for ghostscript-gpl as shown:
echo "app-text/ghostscript-gpl cups" >> /etc/portage/package.use
Then run emerge app-text/ghostscript-gpl. When it has finished compiling, be sure to restart cupsd afterward.
When using OpenRC:
service cupsd restart
When using systemd:
systemctl restart cups
- Using Network Printers - Documentation at CUPS.org.
- Command-Line Printing and Options - Documentation at CUPS.org.
This article is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Sven Vermeulen (SwifT), Joshua Saddler (nightmorph)
They are listed here as the Wiki history does not allow for any external attribution. If you edit the Wiki article, please do not add yourself here; your contributions are recorded on the history page.