CUPS — Print Server
The primary mechanism for Ubuntu printing and print services is the Common UNIX Printing System (CUPS). This printing system is a freely available, portable printing layer which has become the new standard for printing in most Linux distributions.
CUPS manages print jobs and queues and provides network printing using the standard Internet Printing Protocol (IPP), while offering support for a very large range of printers, from dot-matrix to laser and many in between. CUPS also supports PostScript Printer Description (PPD) and auto-detection of network printers, and features a simple web-based configuration and administration tool.
Installation
To install CUPS on your Ubuntu computer, simply use sudo with the apt command and give the packages to install as the first parameter. A complete CUPS install has many package dependencies, but they may all be specified on the same command line. Enter the following at a terminal prompt to install CUPS:
Upon authenticating with your user password, the packages should be downloaded and installed without error. Upon the conclusion of installation, the CUPS server will be started automatically.
For troubleshooting purposes, you can access CUPS server errors via the error log file at: /var/log/cups/error_log . If the error log does not show enough information to troubleshoot any problems you encounter, the verbosity of the CUPS log can be increased by changing the LogLevel directive in the configuration file (discussed below) to “debug” or even “debug2”, which logs everything, from the default of “info”. If you make this change, remember to change it back once you’ve solved your problem, to prevent the log file from becoming overly large.
Configuration
The Common UNIX Printing System server’s behavior is configured through the directives contained in the file /etc/cups/cupsd.conf . The CUPS configuration file follows the same syntax as the primary configuration file for the Apache HTTP server, so users familiar with editing Apache’s configuration file should feel at ease when editing the CUPS configuration file. Some examples of settings you may wish to change initially will be presented here.
Tip
Prior to editing the configuration file, you should make a copy of the original file and protect it from writing, so you will have the original settings as a reference, and to reuse as necessary.
Copy the /etc/cups/cupsd.conf file and protect it from writing with the following commands, issued at a terminal prompt:
sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original sudo chmod a-w /etc/cups/cupsd.conf.original
- ServerAdmin: To configure the email address of the designated administrator of the CUPS server, simply edit the /etc/cups/cupsd.conf configuration file with your preferred text editor, and add or modify the ServerAdmin line accordingly. For example, if you are the Administrator for the CUPS server, and your e-mail address is ‘bjoy@somebigco.com’, then you would modify the ServerAdmin line to appear as such:
ServerAdmin bjoy@somebigco.com
Listen 127.0.0.1:631 # existing loopback Listen Listen /var/run/cups/cups.sock # existing socket Listen Listen 192.168.10.250:631 # Listen on the LAN interface, Port 631 (IPP)
In the example above, you may comment out or remove the reference to the Loopback address (127.0.0.1) if you do not wish cupsd to listen on that interface, but would rather have it only listen on the Ethernet interfaces of the Local Area Network (LAN). To enable listening for all network interfaces for which a certain hostname is bound, including the Loopback, you could create a Listen entry for the hostname socrates as such:
Listen socrates:631 # Listen on all interfaces for the hostname 'socrates'
Port 631 # Listen on port 631 on all interfaces
For more examples of configuration directives in the CUPS server configuration file, view the associated system manual page by entering the following command at a terminal prompt:
Note
Whenever you make changes to the /etc/cups/cupsd.conf configuration file, you’ll need to restart the CUPS server by typing the following command at a terminal prompt:
sudo systemctl restart cups.service
Web Interface
Tip
CUPS can be configured and monitored using a web interface, which by default is available at http://localhost:631/admin . The web interface can be used to perform all printer management tasks.
In order to perform administrative tasks via the web interface, you must either have the root account enabled on your server, or authenticate as a user in the lpadmin group. For security reasons, CUPS won’t authenticate a user that doesn’t have a password.
To add a user to the lpadmin group, run at the terminal prompt:
sudo usermod -aG lpadmin username
Further documentation is available in the Documentation/Help tab of the web interface.
Overview
Ubuntu supports printer sharing over networks, so you can print from your Ubuntu machine, your Windows machine, etc, to another Ubuntu or Windows machine that has a printer attached (ie a «Ubuntu print server» or «Windows print server»).
Background
Ubuntu uses the Common UNIX Printing System («CUPS») to handle printing. CUPS uses the Internet Printing Protocol («IPP») as the basis for managing print jobs and queues. Other protocols are also supported (LPD, SMB, AppSocket a.k.a. JetDirect), some with reduced functionality.
CUPS printer configuration and management is handled by the Printer Admin utility launched from the Gnome menu — System -> Administration -> Printing (If the menu item does not exist you need to add the command system-config-printer to the menu). Also IPP provides web services so after you have configured CUPS appropriately, you can access the printers and jobs via your web browser.
When a locally attached printer is defined, eg using the Printer Admin utility, that printer is automatically published from this «print server» host to the network, depending on the server directives in the CUPS configuration file. A remote Ubuntu «client» host can then be able to see and use the printer attached to the server. The network printer automatically appears in the client’s Printer Admin utility. It simply pops up if CUPS is up and configured correctly and disappears if you stop CUPS at either the Print Server or your local machine.
Ubuntu print server
The Print Server is the Ubuntu computer that is directly connected to the printers.
- On the server machine (the one the printer is attached to), open System -> Administration -> Printing (If the menu item does not exist you need to add system-config-printer to the menu). . This will open the Printer Configuration window.
- Select Server in the menu bar, and then Settings. This will open the Basic Server Settings window.
- Check the second box: Publish shared printers connected to this server If this computer acts as both a Print Server and a client (it does need access to a printer connected to another computer), select also the first box, «Show printers shared by other systems».
- OK
- Right click the printer and check the Shared option, if not checked yet
- Check that users that you want to be able to use the printer are not excluded. See Properties>Access Control. The default settings may be set to «deny printing for everyone except . «
.
But you might want to «allow printing for everyone».
Ubuntu print server compatible with Windows (Samba)
If your Ubuntu print server shall be able to work also with Windows clients, you must first make sure that the SAMBA package is installed (e.g. using Synaptic package manager). Then, do a little configuration change to SAMBA. In brief, you must uncomment the following lines in /etc/samba/smb.conf — open terminal and run:
gksudo gedit /etc/samba/smb.conf
browseable = yes guest ok = yes
sudo service smbd restart sudo service nmbd restart
Also, one would want to allow the following ports through a firewall (ufw for example) via:
sudo ufw allow 139/tcp sudo ufw allow 445/tcp sudo ufw allow 137/udp sudo ufw allow 138/udp
For more on this, please see here.
Printing from Ubuntu
- System -> Administration -> Printing
- Add — Network printer
- Click Find network printer
- Specify the host IP address or name. (It may also work without, try) (IP address worked for me, hostname did not.)
- Click Find
- Printers on the target machine should be found, no matter whether they are connected using CUPS or SAMBA.
- BUT if both protocols are available, e.g. because you have shared your printer on a Linux box both using CUPS and Samba, prefer CUPS (ipp://) over Samba (smb://), because you won’t be prompted to install a driver in general.
- Click Find network printer
- (to be done) What to do if driver is not in the list
Printing from Windows
- Start
- Devices and Printers
- Add a printer
- Add a network, wireless or Bluetooth printer
- Click The printer that I want isn’t listed (unless a miracle happens)
- Enter the address manually (\\servername\MyPrinter). Be sure to respect uppercase/lowercase.
Note that searching or browsing for printers in Windows is notoriously unreliable, as it heavily depends on the network setup. Therefore, it is recommended to enter the printer address manually as shown.
Windows will then probably complain about a missing driver, and offer you to choose one manually. This is the easiest option, so select your printer manufacturer and model from the dialog box. (Alternatively, the Samba configuration could be improved so that the driver would be automatically downloaded.) If your printer model isn’t listed, you may try the «Generic» printer.
Tips: You can avoid intermediate SAMBA buffer using direct connection to CUPS/IPP Ubuntu server from Windows workstation. You should manually specify «http://hostname:631/printers/MyPrinter» IPP URL and select printer driver.
Windows print dialog window (Ctrl-P) can take long time (about 30 seconds) to appear. You can reduce the connection time to CUPS IPP printer by disabling option Automatically detect settings in «Control Panel/Internet Explorer -> Internet Options -> Connections -> LAN settings».
Troubleshooting
1. Bypassing firewall.
If there is an firewall either on print server or the client side, there might appear a communications problem. Use this command to update the firewall to get through.
- This rule is used for IPP only. If you’re using other protocol, such as SAMBA, you have to adapt. You might need to use this rule on both sides (server & client) if the firewall is being used on both of them. To apply this rule after each start/restart of the system, use /etc/rc.local .
2. Networking issues.
Be careful about using different network masks/subnets on your network where you would like to share the printer.
If the subnets differs, e.g. on the print server there would be a /24 (255.255.255.0) netwok mask configured, and e.g. on the clients there would be a /16 (255.255.0.0) network mask — perhaps provided by the DHCP server, this might cause a problem that clients won’t be able to detect any shared printer on the server, even if other communications between print server and clients would be possible (e.g. ICMP, ssh) and successful.
If such situation happens, you have to unify the network masks/subnets on all of your stations, e.g. use /24 (255.255.255.
3. IP address
Generally, it is a good idea to assign your print server a static IP address. Instead, using its host name is also possible, but functionality will then depend on proper configuration of your home router, name service, etc.
4. IPv6 Windows (since XP) can print over IPv6 to Ubuntu Linux (tested between Windows XP SP3 and Ubuntu Linux 8.10). Make sure both the Windows and Ubuntu have IPv6 connectivity. You should tick «Allow Printing from the Internet» on the Ubuntu machine. Then use the URL (which resolves to IPv6) of the Ubuntu machine as described above.
5. Mac OS X 10.5.
Will not find your network printer unless you go to the terminal and run cupsctl BrowseRemoteProtocols=cups (see the CUPS 1.4 documentation at http://www.cups.org/documentation.php/doc-1.4/sharing.html). After doing so, you may need to set the network printer as your default printer for it to show up in program «print» menus.
NetworkPrintingWithUbuntu (последним исправлял пользователь 34 2015-03-31 03:53:29)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details