Computers
Add a Windows Shared Printer in Linux with CUPS and SMB
Written by Printers Setup Editorial Team · Updated

Many homes and small offices have one printer plugged into a Windows PC by USB and shared with everyone else. Windows and Mac users can usually connect with a couple of clicks, but on Linux it takes a little more knowledge. This guide shows how to add a Windows shared printer in Linux using CUPS, the Linux printing system, and its SMB (Windows file and printer sharing) support. The examples use Ubuntu and Debian commands; other distributions work the same way with their own package names.
This is an independent guide. We are not affiliated with Microsoft, Canonical, the Samba project or any printer maker.
First, check whether you need the Windows PC at all
If the printer has Wi-Fi or Ethernet and is already on the network, skip the Windows share and add the printer directly. Direct printing is more reliable and works even when the Windows PC is off. Our guides to adding a printer on Ubuntu and Linux and adding a printer from the Linux command line cover that route.
Use a Windows share when the printer only has USB and is plugged into a Windows computer that stays on when people print.
Step 1: share the printer in Windows
On the Windows PC:
- Install and test the printer locally first.
- Open Settings, Bluetooth & devices, Printers & scanners, select the printer, then Printer properties and the Sharing tab.
- Tick Share this printer and give it a short share name with no spaces, such as
StudyPrinter. - Make sure the network is set to Private and that file and printer sharing is on.
Our share a printer on a network guide has the full Windows steps and the settings that keep the PC visible.
Write down two things: the PC’s name (or better, its IP address) and the share name. You will also need a Windows username and password that is allowed to print, because Windows normally asks for one.
Step 2: install the SMB tools on Linux
CUPS does not talk to Windows shares by itself; it uses a helper called a backend. On Ubuntu and Debian, the smbclient package provides it: Ubuntu’s package file list shows that it installs smbspool and the CUPS smb backend (in the CUPS backend folder), along with the smbclient command.
sudo apt install smbclient
On other distributions, look for the Samba client package (often samba-client).
Step 3: find the exact share name
List what the Windows PC is sharing:
smbclient -L 192.168.1.30 -U yourwindowsuser
Replace the address with your PC’s IP address or name, and the user with your Windows account. The Samba manual describes -L as listing the services a server offers, and -U as setting the username. Enter the Windows password when asked. Look for a line of type Printer; the name in the first column is the share name.
Step 4: add the printer
With a graphical tool
Many desktops include a print settings tool built on CUPS (often called Print Settings or system-config-printer). Choose Add, then under Network Printer pick Windows Printer via SAMBA, enter the address in the form smb://192.168.1.30/StudyPrinter, fill in the authentication details and choose a driver for your printer model. If your desktop’s Settings app only offers network IPP printers, use the command line below or the CUPS web interface instead.
From the command line
The Samba smbspool manual lists the address formats CUPS understands:
smb://server/printer
smb://workgroup/server/printer
smb://user:pass@server/printer
smb://user:pass@workgroup/server/printer
First, find a driver for the printer model:
lpinfo -m | grep -i "laserjet"
Replace laserjet with part of your model name. Then create the queue:
sudo lpadmin -p StudyPrinter -E \
-v smb://printuser:password@192.168.1.30/StudyPrinter \
-m "MODEL-FROM-LPINFO"
Replace MODEL-FROM-LPINFO with the first column of the matching lpinfo -m line, which is the driver name CUPS expects. Then print a test page:
lp -d StudyPrinter /usr/share/cups/data/testprint
If that file is not present on your system, print any small PDF instead.
Why you need a driver here
On a direct network connection, most modern printers work with the IPP Everywhere driverless model (-m everywhere). The CUPS lpadmin manual explains that this model queries the printer at an IPP address, which a Windows share does not have. Over SMB, Linux prepares the print data and Windows passes it on to the printer, so Linux needs a driver that speaks the printer’s language. If your exact model is missing, a generic PCL or PostScript driver often works for laser printers that support those languages; check the printer’s specifications.
The same manual also notes that CUPS printer drivers and PPD files are deprecated and will lose support in a future feature release. A Windows share is therefore a workable bridge, but a printer on the network with IPP is the long-term answer. A small Raspberry Pi print server or a router with a USB print server can take over from the Windows PC.
Using the CUPS web interface instead
If you prefer a browser, CUPS has its own administration pages on the Linux computer at http://localhost:631. Select Administration, then Add Printer, and sign in with your Linux administrator account when asked. Under other network printers, choose Windows Printer via SAMBA, enter the same smb:// address, give the printer a name, and pick the make and model on the next page. The result is the same queue that lpadmin creates, so you can mix both methods. Our Ubuntu printer guide shows the web interface in more detail.
Check the queue
After adding the printer, confirm that CUPS accepted it:
lpstat -p StudyPrinter -v
The output should show the printer as idle and enabled, with the smb:// device address you entered. If it shows as disabled, enable it with sudo cupsenable StudyPrinter and accept jobs with sudo cupsaccept StudyPrinter.
Passwords and security
Putting the username and password into the address is simple, but it stores them in the CUPS configuration on the Linux computer. Reduce the risk:
- Create a separate Windows account used only for printing, with its own password.
- Do not reuse the password of your main Windows or email account.
- Keep SMB sharing to your private home network; never expose it to the internet. Our printer network ports guide lists the SMB ports (139 and 445) involved.
Troubleshooting
- “Unable to connect” or name not found. Use the PC’s IP address instead of its name, and reserve that address in the router; see find a device’s IP address.
- Access denied. Check the username and password with
smbclient -Lfirst. A Microsoft account on Windows usually signs in with the account’s email address and its password. - Share name with spaces. Rename the share without spaces, or write each space as
%20in the address. - Jobs vanish or print garbage. The driver is wrong for the printer. Delete the queue (
sudo lpadmin -x StudyPrinter) and add it again with another driver. - Nothing prints when the Windows PC is asleep. The PC must be awake. Adjust its sleep settings, or move the printer to the network.
- Windows needs the driver too. The printer must print from Windows itself; if it does not, fix that first using our Windows 11 driver guide.
Frequently asked questions
Can Linux print to a printer shared from Windows 11?
Yes. CUPS prints to Windows shares through its smb backend, which on Ubuntu and Debian comes with the smbclient package. The Windows PC must be switched on and its printer shared.
What is the smb printer address format?
The Samba smbspool manual lists smb://server/printer, smb://workgroup/server/printer, and forms with username:password@ before the server. Use the Windows share name, not the printer's full display name.
Why can I not use the IPP Everywhere driver for a Windows shared printer?
The CUPS lpadmin manual says the everywhere model queries the printer at an IPP address. A Windows share is reached over SMB, not IPP, so pick a driver for the printer model, or a generic PCL or PostScript driver the printer understands.
Is it safe to put my Windows password in the printer address?
It works but stores the password in the CUPS configuration. A safer habit is a separate Windows account with a password used only for printing, rather than your main account.
Why does Linux not find the Windows computer by name?
Name lookup between Linux and Windows does not always work on home networks. Use the PC's IP address in the smb address instead, and reserve that address in your router so it does not change.
Sources
Editorial team
The Printers Setup team writes and reviews step-by-step printer setup guides and checks them against the current menus of Windows, macOS, ChromeOS, iOS and Android.


