Setting Up Printer Support with CUPS on FreeBSD
Categories:
7 minute read
FreeBSD is a powerful and stable operating system popular among system administrators and hobbyists alike. While FreeBSD excels at many tasks, printing functionality requires some additional configuration. The Common Unix Printing System (CUPS) provides a robust printing solution for FreeBSD users. This guide will walk you through the process of setting up CUPS on FreeBSD, from installation to printer configuration and troubleshooting.
Introduction to CUPS
The Common Unix Printing System (CUPS) is an open-source printing system developed by Apple Inc. that has become the standard printing solution for most Unix-like operating systems. CUPS uses the Internet Printing Protocol (IPP) to manage printers, print queues, and print jobs. It features a web-based administration interface, command-line tools, and supports various printer drivers and formats.
Prerequisites
Before proceeding with CUPS installation and configuration, ensure you have:
- A FreeBSD system (version 12.0 or newer recommended)
- Root or sudo access to the system
- A supported printer (check the CUPS supported printer database for compatibility)
- Network connectivity (if setting up a network printer)
- Basic familiarity with FreeBSD package management and system administration
Installation Process
Step 1: Installing CUPS and Required Packages
First, update your FreeBSD system to ensure you have the latest package information:
# Update the package repository
pkg update
Next, install CUPS and related packages:
# Install CUPS
pkg install cups print/cups-filters print/gutenprint
The above command installs:
cups
: The core CUPS printing systemcups-filters
: Additional filters for processing various document formatsgutenprint
: High-quality printer drivers for many printer models
For PDF support, install Ghostscript:
pkg install print/ghostscript9-base
Step 2: Enabling CUPS Service
After installation, you need to enable and start the CUPS service:
- Add the following line to
/etc/rc.conf
to enable CUPS at boot time:
# Enable CUPS service at boot
echo 'cupsd_enable="YES"' >> /etc/rc.conf
- Start the CUPS service:
# Start CUPS service
service cupsd start
- Verify that CUPS is running:
# Check CUPS status
service cupsd status
Step 3: User Setup
For proper access to CUPS and printer management, you should add your user to the cups
group:
# Add user to cups group
pw groupmod cups -m yourusername
You may need to log out and log back in for this change to take effect.
Accessing the CUPS Web Interface
CUPS provides a web-based administration interface for managing printers and print jobs. To access it:
- Open a web browser on your FreeBSD system or another computer on the same network
- Navigate to:
http://localhost:631/
(or replacelocalhost
with your FreeBSD machine’s IP address if accessing from another computer)
By default, CUPS might restrict remote administration. To enable it:
- Edit the CUPS configuration file:
vi /usr/local/etc/cups/cupsd.conf
- Modify the
Listen
directive to listen on all network interfaces:
Listen 0.0.0.0:631
- Find the
<Location />
,<Location /admin>
, and<Location /admin/conf>
sections and add the following line inside each section:
Allow @LOCAL
- Restart CUPS to apply changes:
service cupsd restart
Adding and Configuring Printers
Local USB Printer Setup
- Connect your printer to the FreeBSD system via USB and power it on
- Access the CUPS web interface at
http://localhost:631/
- Click on the “Administration” tab
- Click “Add Printer”
- You’ll be prompted for authentication - use your root username and password
- Select your USB printer from the list of detected devices
- Follow the prompts to provide a name, description, and location for your printer
- Select the appropriate driver for your printer model
- Set default printing options as needed
Network Printer Setup
- Ensure your network printer is powered on and connected to the same network as your FreeBSD system
- Access the CUPS web interface at
http://localhost:631/
- Click on the “Administration” tab
- Click “Add Printer”
- Select the appropriate protocol for your network printer:
- For IPP printers: Select “Internet Printing Protocol (ipp)”
- For HP printers: Select “HP Jetdirect”
- For Windows shared printers: Select “Windows Printer via SAMBA”
- Provide the printer’s network address or URI
- For IPP:
ipp://printer_ip/ipp/print
oripp://printer_ip/ipp
- For HP Jetdirect:
socket://printer_ip:9100
- For SAMBA:
smb://username:password@workgroup/server/printer
- For IPP:
- Follow the prompts to provide a name, description, and location for your printer
- Select the appropriate driver
- Set default printing options as needed
Driver Installation
For many printers, the drivers included with CUPS and Gutenprint will be sufficient. However, some printers may require specific drivers:
PostScript Printers
Most PostScript printers work with the Generic PostScript driver included with CUPS.
HP Printers
For HP printers, install HPLIP:
pkg install print/hplip
After installation, you can use the hp-setup
command to set up your HP printer:
hp-setup -i
Brother Printers
For Brother printers, you may need to download drivers from the Brother website and install them manually. Check the Brother website for FreeBSD-compatible drivers or Linux drivers that may work with FreeBSD.
Testing and Using Your Printer
Testing the Printer
After adding a printer, you should test it:
- From the CUPS web interface, click on the “Printers” tab
- Click on your printer’s name
- Click on “Maintenance” and select “Print Test Page”
Alternatively, use the command line:
lpr -P printer_name /usr/local/share/cups/data/testpage.pdf
Printing from Applications
Most FreeBSD applications that support printing should automatically detect CUPS printers. In applications, look for print options and select your configured printer.
Command-Line Printing
CUPS provides several command-line tools for printing:
lpr
: Print fileslpr -P printer_name filename
lpq
: View print queuelpq -P printer_name
lprm
: Remove print jobslprm -P printer_name job_id
Advanced Configuration
Setting Default Printer
Set a default printer with:
lpoptions -d printer_name
Printer Classes
Printer classes allow you to group multiple printers. When printing to a class, the job is sent to the first available printer in that class.
To create a printer class:
- Access the CUPS web interface
- Click on “Administration” and then “Add Class”
- Provide a name, description, and location
- Select the printers to include in the class
Custom Paper Sizes
To define custom paper sizes:
- Access the CUPS web interface
- Click on “Administration” and then “Server Settings”
- Scroll down to “Custom Paper Sizes” and click “Add Custom Paper Size”
- Define your custom paper dimensions and margins
Troubleshooting Common Issues
Printer Not Detected
If your USB printer is not detected:
Check USB connections
Verify the printer is powered on
Check if the device is recognized by the system:
dmesg | grep -i usb
Ensure necessary device drivers are loaded:
kldstat
You may need to load additional kernel modules for specific USB devices
Print Jobs Stuck in Queue
If print jobs get stuck in the queue:
Check the printer status and make sure it’s online
Cancel all pending jobs:
cancel -a
Restart CUPS:
service cupsd restart
Driver-Related Issues
If you experience driver-related issues:
- Try alternative drivers from the CUPS web interface
- Check printer manufacturer’s website for FreeBSD-compatible drivers
- Consider using a generic driver if a specific one is not available
Permission Problems
If you encounter permission errors:
Verify your user is in the
cups
groupCheck file permissions for CUPS configuration files:
ls -la /usr/local/etc/cups/
Ensure proper permissions on the printer device:
ls -la /dev/ulpt*
Security Considerations
CUPS provides several security features to protect your printing environment:
Encrypting Print Jobs
To enable encryption for print jobs:
Edit the CUPS configuration file:
vi /usr/local/etc/cups/cupsd.conf
Add or modify:
DefaultEncryption IfRequested
Restart CUPS:
service cupsd restart
Restricting Access
To limit access to specific IP addresses:
Edit the CUPS configuration file
Modify the
<Location>
sections:<Location /> Order allow,deny Allow from 192.168.1.0/24 Allow from 127.0.0.1 </Location>
Apply similar restrictions to other
<Location>
sections as neededRestart CUPS
Conclusion
Setting up CUPS on FreeBSD provides a robust printing solution compatible with a wide range of printers. By following this guide, you should have a fully functional printing system for your FreeBSD environment. While the initial configuration may require some effort, CUPS offers excellent reliability and flexibility once set up.
Remember to keep your CUPS installation updated along with your FreeBSD system to benefit from the latest features and security fixes. For more advanced configurations or specific printer models, consult the CUPS documentation or the FreeBSD Handbook.
Additional Resources
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.