Yes, you can share a printer on Linux using CUPS and Samba so other computers—especially Windows machines—can access it over the network. This guide walks you through setting up printer sharing by configuring CUPS to allow network access and using Samba to expose the printer to Windows and other Samba-compatible systems.

What You'll Need

  • A Linux machine with a working printer connected and configured in CUPS
  • Root or sudo access to install and configure services
  • CUPS (Common Unix Printing System) installed and running
  • Samba installed and configured
  • Network access between the Linux host and client devices
  • A firewall configured to allow CUPS and Samba traffic (ports 631, 139, 445)

Step-by-Step

  1. Ensure CUPS is installed and running. Most Linux distributions include CUPS by default. To verify, run sudo systemctl status cups. If it's not active, start it with sudo systemctl start cups and enable it on boot: sudo systemctl enable cups.
  2. Configure CUPS to allow remote access. Edit the CUPS configuration file located at /etc/cups/cupsd.conf. Open it with a text editor: sudo nano /etc/cups/cupsd.conf.
  3. Inside cupsd.conf, find the line that reads Listen localhost:631. Change it to Listen :631 to allow connections from any IP on port 631.
  4. Add or modify the following blocks to allow access from your local network. Replace 192.168.1.* with your network subnet if different:
    <Location />
      Order allow,deny
      Allow @LOCAL
    </Location>
    
    <Location /admin>
      Order allow,deny
      Allow @LOCAL
    </Location>
    
    <Location /admin/conf>
      Order allow,deny
      Allow @LOCAL
    </Location>
    The @LOCAL directive allows access from the local network. Alternatively, use Allow 192.168.1.* for explicit subnet control.
  5. Restart CUPS to apply changes: sudo systemctl restart cups.
  6. Install Samba if not already installed: sudo apt install samba (Debian/Ubuntu) or sudo dnf install samba (Fedora/RHEL).
  7. Backup and edit the Samba configuration: sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak, then open /etc/samba/smb.conf in your editor.
  8. Add a printer share section at the end of the file:
    [printers]
      comment = All Printers
      path = /var/spool/samba
      browseable = yes
      printable = yes
      guest ok = yes
      read
      create mask = 0700
    
    [print$]
      comment = Printer Drivers
      path = /var/lib/samba/printers
      browseable = yes
      read
      guest ok = yes
    This exposes all CUPS printers via Samba and sets up a location for Windows clients to download drivers.
  9. Create the spool directory for Samba: sudo mkdir -p /var/spool/samba and set permissions: sudo chown -R root:lp /var/spool/samba and sudo chmod 755 /var/spool/samba.
  10. Ensure the Samba service starts: sudo systemctl start smb and sudo systemctl enable smb. On some systems, the service is named smbd instead.
  11. Configure the firewall to allow CUPS and Samba. Open ports 631 (CUPS), 139 and 445 (Samba). For example, on systems using ufw: sudo ufw allow 631/tcp, sudo ufw allow 139/tcp, sudo ufw allow 445/tcp.
  12. On a Windows machine, open File Explorer and navigate to . You should see the shared printer. Double-click to install it. Windows may prompt to install drivers; use the generic ones if needed.
  13. Test printing from the Windows client. If the print fails, check logs at /var/log/cups/error_log and /var/log/samba/log.smbd.

Common Mistakes

  • Forgetting to restart CUPS after changing cupsd.conf—the config won’t take effect.
  • Leaving Listen localhost:631 unchanged, blocking remote access.
  • Incorrect Samba share paths or permissions on /var/spool/samba.
  • Firewall blocking ports 631, 139, or 445.
  • Using Allow from localhost instead of Allow @LOCAL or a subnet.
  • Not enabling Samba services at boot, leading to failed access after reboot.

Tips

  • Use @LOCAL in CUPS for simplicity unless strict access control is needed.
  • Set up a static IP for the Linux machine to avoid client reconfiguration.
  • Use testparm to validate Samba config: sudo testparm.
  • Check printer sharing status in CUPS web interface at http://localhost:631 under Administration > Sharing.
  • For mixed networks, ensure NetBIOS name resolution works—Samba relies on it.

Troubleshooting

If the printer doesn’t appear or won’t print:

  • Verify CUPS is running: sudo systemctl status cups.
  • Check CUPS listens on all interfaces: run sudo netstat -tuln | grep 631. You should see 0.0.0.0:631 or :::631.
  • Test Samba shares: run smbclient -L localhost -U% to list shares locally.
  • Inspect CUPS logs: sudo tail -f /var/log/cups/error_log while attempting to print.
  • Ensure the printer is marked as shared in CUPS.
  • On Windows, ensure SMBv1 is disabled unless required—modern Samba uses SMBv2/3.
  • If access is denied, verify Samba user permissions. You may need to add a Samba user with sudo smbpasswd -a [username].

Frequently Asked Questions

Can Windows connect to a CUPS printer via Samba?

Yes, once Samba shares the CUPS printer, Windows can connect using the network path \\IP-ADDRESS and install it as a network printer.

Do I need to install printer drivers on the Linux machine?

No, CUPS handles driver processing. Windows clients download drivers via the [print$] share, or use built-in ones.

Is it safe to allow @LOCAL in CUPS?

Yes, if your network is trusted. For public networks, restrict access to specific IPs instead.

What if the printer appears but won't print?

Check CUPS processing errors, ensure the printer is accepting jobs, and verify file permissions on the spool directory.

Can multiple users print simultaneously?

Yes, CUPS manages print queues and Samba allows concurrent access by design.

Does this work with macOS?

Yes, macOS supports IPP and SMB printing. Use the IP address and printer name in System Settings > Printers.