X
Tech
Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.

Close

How to share a printer on Linux with CUPS and Samba

Some Linux distributions make sharing printers far easier than others. If your distribution doesn't include a GUI for printer sharing, you'll have to use the command line.
Written by Jack Wallen, Contributing Writer
Person using printer
Krit of Studio OMG/Getty Images

You might have read about my recent spate of distro hopping, where I landed with Ubuntu Budgie as my primary operating system. A few days after installing the OS, I realized I'd forgotten that I always share my Public folder to my internal network, so I can easily share files between machines (without having to email them or bounce them between machines and any given cloud service). 

I quickly realized that Ubuntu Budgie not only didn't have a simple means of sharing folders to a network, it also didn't include a GUI method for sharing printers. Given my wife is always printing out knitting patterns, return labels, and other bits of information (and the only printer in the house is attached to my desktop), I had to get that printer shared before I was inundated with things to print for her.

Also: How to choose the right Linux desktop distribution for you

Fortunately, this isn't my first rodeo with printer sharing in Linux, so it only took me a couple of minutes to get that up and running. If you have a similar need, let me show you how easy it is to share a printer to your LAN with CUPS (Common Unix Printer Service) and Samba, which provides file and print services between clients across various operating systems.

One thing to keep in mind as you do this -- printers can be very finicky, so not every setup works with every piece of hardware. Just ask any IT admin for their opinion on printers and you'll get an earful.

How to share a printer to your LAN from Linux

What you'll need: The only things you'll need for this process are a running instance of Linux, a printer already attached (and working), and a user with sudo privileges. 

Also: 8 things you can do with Linux that you can't do with MacOS or Windows

I'll demonstrate on Ubuntu Budgie, which is based on Ubuntu. If you use a different distribution, the only thing you should need to change is the command for installing Samba. That's it. Let's get to work.

1. Install Samba

In case Samba isn't already installed, you can do so by opening a terminal window and issuing the command:

sudo apt-get install samba -y

2. Start and enable Samba

After the installation, you'll want to make sure Samba is set to start at boot, which can be done with the command:

sudo systemctl enable --now smb

3. Configure Samba

Next, we'll configure Samba. Open the smb.conf file with the command:

sudo nano /etc/samba/smb.conf

First, look for the line that starts printing = and change it to:

printing = CUPS

Next, locate the [printers] section and make sure it looks like this:

[printers]
   comment = All Printers
   browseable = yes
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   read only = yes
   create mask = 0700

Save and close the file by hitting the Ctrl+x keyboard shortcut.

4. Configure CUPS

It's now time to configure CUPS. Open the config file with the command:

sudo nano /etc/cups/cupsd.conf

The first line to identify will look like this:

Listen localhost:631

Change localhost to the IP address of the machine hosting the printer (which you can find by running the command ip a).

Also: The most important reason you should be using Linux at home

Next, you need to set Browsing to yes. Look for the line:

# Show shared printers on the local network.

Make sure the following is directly below it:

Browsing Yes

In the same file, look for the section that starts with:

<Location />

That section should look something like this (making sure to change the IP address to that of your network):

<Location />
  Order allow,deny
  Allow localhost
  Allow 192.168.1.*
</Location>

Save and close the file.

5. Restart Samba

Since we've changed the Samba configuration file, we need to restart the service with the command:

sudo systemctl restart smb

6. Restart CUPS

Finally, we need to restart CUPS with the command:

sudo systemctl restart cups

At this point, the printer attached to your Linux machine should appear on your network. One thing you might have to do is download and install the printer drivers to the machine you plan to print from. 

Also: Thinking about switching to Linux? 6 things you need to know

This action will depend on the printer you use and whether support for that printer is baked into the operating system you intend to print from. If you go to print from the shared printer and find your OS can see the printer but not print to it, download and install the printer driver and you should be good to go. 

Editorial standards