How to share an installed printer in linux/Debian in network
Sharing an installed printer in Debian on a network can be done using CUPS (Common Unix Printing System), which is the standard printing system for most Linux distributions.1
Step 1: Install CUPS and Printer Drivers
First, ensure you have CUPS and the necessary printer drivers installed. If you installed your printer, you likely already have these. If not, open a terminal and run:
Bash
sudo apt update
sudo apt install cups
You’ll also need to install the printer’s drivers. Search for them by name, like so:
Bash
sudo apt search printer-driver
Install the one that matches your printer. For a general set of drivers, you can install printer-driver-gutenprint:
Bash
sudo apt install printer-driver-gutenprint
Step 2: Configure CUPS for Network Sharing
By default, CUPS only allows connections from the local machine.2 To enable network sharing, you need to modify its configuration file.
- Open the CUPS configuration file, /etc/cups/cupsd.conf, with a text editor. Use nano for simplicity:
Bash
sudo nano /etc/cups/cupsd.conf - Find the lines that begin with <Location />, <Location /admin>, and <Location /printers>.
- In each of these sections, add the following lines to allow access from other computers on your network. Replace 192.168.1.0/24 with your network’s address range.
# Allow network access Order allow,deny Allow all
A simpler, less secure option is to use Allow @local.
- Change the line Listen localhost:631 to Listen *:631 to allow CUPS to listen on all network interfaces, not just the loopback address.
After editing, the sections should look something like this:<Location /> Order allow,deny Allow all </Location> <Location /admin> Order allow,deny Allow all </Location> <Location /printers> Order allow,deny Allow all </Location>
- Save the changes and exit the text editor (in nano, press Ctrl + O, then Enter, and then Ctrl + X).
Step 3: Restart CUPS and Enable Web Interface
Restart the CUPS service for the changes to take effect:
Bash
sudo systemctl restart cups
Next, to enable the CUPS web interface, which is a key part of managing printers, add your user to the lpadmin group:
Bash
sudo usermod -a -G lpadmin your_username
Replace your_username with your actual username. You will need to log out and log back in for this change to take effect.
Step 4: Share the Printer via Web Interface
Now, you can use the CUPS web interface to share your printer.
- Open a web browser and navigate to http://localhost:631.
- Go to the “Printers” tab.
- Click on the printer you want to share.
- From the “Administration” drop-down menu, select “Set as Server Default” or “Modify Printer”.
- On the next page, check the box that says “Share this printer” or similar.
- Follow the prompts to save your changes.
Your printer is now discoverable and available for use by other computers on your network. 🖨️