CIQ

How to Share a Printer with Samba and Cups

How to Share a Printer with Samba and Cups
December 5, 2023

Rocky Linux can do so much. It can serve as your desktop operating system; it can serve up websites, databases, containers… you name it, and Rocky Linux can probably do it.

Another very handy service Rocky Linux can take care of is a printer server. Why would you want to do that? You could attach a printer to your Rocky Linux instance and make it such that anyone on your network can send print jobs to that one location. Attach multiple printers to the server, and those on your LAN can select the printer they want to add.

Anyone who's ever had to offer a printer to multiple users (be it in a home or business) understands the necessity of this. It's more efficient and more cost-effective (rather than purchasing and adding printers to every person's desktop).

So, how do you pull this off with Rocky Linux? Let us show you.

What you'll need

First off, you'll need a running instance of Rocky Linux. You'll also need a working printer attached to the instance. How you pull that off will depend on the printer, so before you attempt to share the printer, make sure it works as expected on Rocky Linux. This may (or may not) include installing the proper drivers for your printer. Again, that will depend on the make and model of the printer in question. You'll also need a user with sudo privileges.

That's it. Let's get to work.

Installing Samba

If you haven't already, you'll need to install Samba, which makes the attached printer discoverable on your network. One thing to keep in mind is that you don't have to install Samba when going Linux to Linux, but you might find Samba to be a bit more flexible because it allows you to share both printers and folders to your network. 

To install Samba, log into Rocky Linux, open a terminal window, and issue the command:

sudo dnf install samba -y

Once Samba is installed, start and enable the service with the command:

sudo systemctl enable --now smb

Configuring Samba

We can now configure Samba such that it serves up your printers. First, look for the line in the [global] section that starts with printing = and make sure it reads:

printing = cups

Next, locate the [printing] block and make sure it reads:

[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. Restart Samba with:

sudo systemctl restart smb

Configure the CUPS printing service

Next, we have to configure the CUPS printing service to share out the printers to your network. Open the CUPS configuration file with:

sudo nano /etc/cupsd.conf

In that file, locate the line:

Listen localhost:631

Change localhost to the IP address of the Rocky Linux server (which you can find with the command ip a). Next, locate the line:

Show shared printers on the local network. Make sure the line after that is:

Browsing Yes

Next, locate the block that starts with:

<Location />

Make sure that section looks like the following:

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

Of course, you'll want to edit the IP address scheme so it matches your network. For example, if your network uses a 10.0.1.x scheme, that line would read:

Allow 10.0.1.*

Save and close the file.

Restart the CUPS daemon with:

sudo systemctl restart cups

Your Rocky Linux machine is now serving any printer that has been successfully attached. You can then connect any desktop machine to the printer server and start printing. Do note, however, that you might have to install drivers for the printer on each desktop machine. That will depend on the printer and the operating system used. For example, some Linux distributions can use a generic driver to send jobs to a printer. In those cases, however, your users might not be able to gain access to all the features offered by the printer, so installing the drivers on desktop machines might be your best bet.

Congratulations! You can now use Rocky Linux as a convenient printer server on your local area network.

Related posts

2023 Holiday Gift Guide for Rocky Linux Users

2023 Holiday Gift Guide for Rocky Linux Users

Dec 19, 2023

Rocky Linux

Why Rocky Linux Is a Rock-Solid Choice in an Economic Downturn

Why Rocky Linux Is a Rock-Solid Choice in an Economic Downturn

Jan 18, 2023

Rocky Linux

6 Signs That It's Time to Move to Rocky Linux

6 Signs That It's Time to Move to Rocky Linux

Feb 23, 2023

Rocky Linux

123
39
>>>