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.
- 1 Printing and Gentoo Linux
- 2 Configure your Kernel
- 3 Installing and Configuring CUPS
- 4 Configuring a Printer
- 5 Using Special Printer Drivers
- 6 Printing From and To Microsoft Windows
- 7 Printing-related Applications
- 8 Troubleshooting
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.
Configure your Kernel
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 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 using the following command:
make && make modules_install
Do not forget to copy the newly compiled kernel image to the /boot location. If applicable mount /boot, and update the boot loader configuration prior to rebooting the system. For instance, when using GRUB2, these steps can be done by running the following commands:
grub2-mkconfig -o /boot/grub.grub.cfg
Now continue with CUPS.
Locally Attached Printer (USB)
To print via USB, USB support must be enabled in the kernel:
Device Drivers --> USB Support --> <*> Support for Host-side USB (...) --- USB Host Controller Drivers (Select the HCD that your system uses. If you do not know which one to select, run "lspci -v | grep HCI" from another terminal) <*> EHCI HCD (USB 2.0) support ( or ) <*> OHCI HCD support ( or ) <*> UHCI HCD (most Intel and VIA) support
Exit the kernel configuration and rebuild the kernel. Do not forget to copy the new kernel image to the /boot location (if necessary mount the /boot partition before copying the kernel) and update the boot loader configuration prior to rebooting the system. Note the root commands listed in the LPT Printer Configuration step above for how to perform these steps.
Now continue with CUPS.
Remotely Attached Printer (IPP)
To be able to connect to a remotely attached printer through the Internet Printing 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 CUPS.
Installing and Configuring CUPS
Installing CUPS with Gentoo is a breeze. 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 flag (what is that?)||Default||Recommended||Description|
||No||Allows the user to use a desktop menu to load the CUPS configuration webpage into a preferred browser.|
||No|| Adds support for the |
||No||If print job authentication through the Pluggable Authentication Modules is needed, this will activate PAM support for CUPS.|
||No||If remote authentication and/or privacy is required support for the Secure Socket Layer must be enabled which will allow for encrypted printing sessions. Support for SSL must be available on all participating systems on the network.|
||No||Support for working with printers connected via USB.|
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 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, have Portage install CUPS.
emerge --ask 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
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
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.
rc-update add cupsd default
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:
pre> <Location /admin> (...) Encryption Required Order allow,deny Allow localhost Allow 192.168.0.3 </Location> </pre>
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.
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.
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
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 should contain 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 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 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 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 splix
Printing From and To Microsoft Windows
You should 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
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 Gtk-LP 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.
To install it, emerge gtklp:
emerge --ask gtklp
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
This article is based on a document formerly found on our main website gentoo.org.
The following people have contributed to the original document: swift, nightmorph
They are listed here as the Wiki history does not provide for any attribution. If you edit the Wiki article, please do not add yourself here, your contributions are recorded on the history page.