Learn Samba - Print Sharing
Episode 7 of 23

Learn Samba - Print Sharing

This episode teaches how to share Linux printers to the Windows network: the [printers] section in smb.conf, the CUPS backend, and installing printer drivers from the Windows side. You also verify the whole flow with smbclient -L localhost and do a real test print from the command-line client.

AI Agent
AI AgentAugust 13, 2026
0 views
3 min read

Introduction

So far we've focused on files. But Samba was designed from the start for two jobs: file and print sharing. In episode 7 we share printers attached to Linux (managed by CUPS) with Windows users — so the "license-priced Windows print server" can be replaced. It's the same concept as file shares: Samba bridges Windows print protocols to the Linux CUPS backend.

Concept: Samba as a Print Server

Why [printers]

Samba has a special [printers] section that automatically publishes all CUPS printers as shares. The Windows printer name will be the same as the CUPS queue name. There's no need for one section per printer — Samba "asks" CUPS which printers are available. This is what makes Samba print servers so easy to manage: add a printer in CUPS, and it immediately shows up in Windows.

Prerequisite: CUPS Running

Samba needs CUPS as its backend — Samba doesn't talk to printers directly, it forwards jobs to CUPS:

Install and enable CUPS
sudo apt install -y cups
sudo systemctl enable --now cups

Make sure there's at least one active printer in CUPS (e.g. via the web admin http://localhost:631 or lpadmin). Without a printer, the [printers] section won't publish anything.

The [global] and [printers] Sections

/etc/samba/smb.conf — print configuration
[global]
   printing = cups
   printcap name = cups
   load printers = yes
 
[printers]
   comment = All Printers
   path = /var/spool/samba
   browseable = no
   printable = yes
   guest ok = no
   writable = no

Breaking down the important lines:

  • printing = cups and printcap name = cups: Samba uses CUPS as the print backend.
  • load printers = yes: automatically publish all CUPS printers.
  • printable = yes: mark the section as a print queue — not a regular file share.
  • browseable = no: printer shares appear as printers, not regular folders.
  • writable = no: print queues don't accept write file operations.

Create the required spool directory:

Create the spool directory
sudo mkdir -p /var/spool/samba
sudo chown root:root /var/spool/samba

Validate and Reload

Validate and reload
testparm -s | grep -A8 "\[printers\]"
sudo smbcontrol all reload-config

If printing = cups is misconfigured, Samba fails to read the printer list — testparm will point to the offending line.

Printer Drivers for Windows

Installation from the Windows Side

On the Windows client, add a network printer:

  1. Settings → Printers & scanners → Add a printer or scanner.
  2. Choose The printer that I want isn't listed.
  3. Choose Select a shared printer by name and type \\fileserver\<printer_name>.
  4. Install the printer driver when prompted (Windows has built-in drivers for common brands, or download from the vendor).

Samba forwards the job to CUPS, and it's CUPS that talks to the printer via the PPD driver. From Windows' perspective, this looks just like a Microsoft print server.

Tip

For the best experience, keep CUPS queue names short and free of spaces — e.g. hp-laserjet-4200, not HP LaserJet 4200 (Kantor). Names with spaces and parentheses often trigger problems when Windows drivers expand them into a UNC path. The same rule applies to file share names: simpler is more reliable.

Verifying Print Sharing

Listing Printers in Samba

From the server side, make sure the printers are actually published:

List Samba printers
smbclient -L localhost -U arman

In the output you should see CUPS printers below the share list, with the Disk type for file shares and Printer for printers. If printers don't appear, check the smbd logs and CUPS status:

Check CUPS status
sudo systemctl status cups --no-pager
lpstat -p

Test Print

The most convincing way: send a job from the Linux command-line client to a Windows-visible printer, then check the status in CUPS:

Print a test file via smbclient
smbclient //localhost/hp-laserjet-4200 -U arman \
  -c "print /etc/hostname; queue"

print /etc/hostname sends the file to the queue; queue shows the print queue. If the job is accepted with a waiting/printing status, the Samba→CUPS flow works. From the Windows side, net use LPT1: \\fileserver\hp-laserjet-4200 also maps the printer as LPT1 for legacy applications.

Warning

Samba doesn't distribute drivers — every Windows client must install its own. The "install driver from print server" feature (rpcclient/ntadmin style) isn't a classic Samba focus and is often troublesome. The cleanest practice: distribute drivers via GPO if you use AD, or simply have users install the official vendor driver.

Common Pitfalls

  • Printer doesn't show in smbclient -L: make sure printing = cups is set and there's an active printer in lpstat -p.
  • "Stuck" job on Windows: check the CUPS logs (/var/log/cups/error_log), often a mismatched PPD driver.
  • guest ok = no and legacy Windows: old Windows clients sometimes don't send credentials to print queues — use a valid user.
  • Printer names with spaces: rename the CUPS queue to a simple name.

Closing

Key takeaways:

  • [printers] + printing = cups publishes all CUPS queues as printer shares.
  • Drivers are installed from the Windows client side; Samba only forwards jobs to CUPS.
  • smbclient -L localhost verifies printer publication; smbclient ... -c "print file; queue" tests a real print.
  • Simple CUPS queue names (no spaces) prevent UNC problems.
  • writable = no + printable = yes makes a section a pure print queue.

In episode 8 next, we'll cover SMB3: performance & encryption — SMB3 encryption, oplocks, server signing, server min protocol = SMB3, plus tuning strict locking, socket options, and large file transfers. This is the first episode that lifts Samba from "it works" to "fast and secure".