# Share your printer with CUPS

I have a printer in my office, but sometimes I work on my laptop in another room of the house.
This isn't a problem for me for two reasons.
First of all, I rarely print anything to paper and have gone months without using the printer.
Secondly, though, I've set the printer to be shared over my home network, so I can send files to print from anywhere in the house.
I didn't need any special equipment for this setup, it's accomplished with just my usual Linux computer and the Common Unix Printing System (CUPS).

## Installing CUPS

If you're running Linux, BSD, or macOS, then you probably already have CUPS installed.
CUPS has been the open source solution to Unix printing since 1997.
Apple relied on it so heavily for their fledgling Unix-based OS X that they ended up buying it in 2007 to ensure its continued development and maintenance.

If your system doesn't already have CUPS installed, you can install it with your package manager.
For example, on Fedora, Mageia, or CentOS:

```bash
$ sudo dnf install cups
```

On Debian, Linux Mint, and similar:

```bash
$ sudo apt install cups
```

## Accessing CUPS

To access CUPS, open a web browser and navigate to localhost:631, which tells your computer to open whatever's on port 631 on itself (your computer always [refers to itself as `localhost`](https://opensource.com/article/21/4/network-management)).

Your web browser opens a page providing you access to your system's printer settings.
From here, you can add printers, modify printer defaults, monitor queued jobs, and allow printers to be shared over your local network.

![The CUPS interface](cups-web-ui.jpg)

## Configuring a printer with CUPS

You can either add a new printer or modify an existing one from within the CUPS interface.
Modifying a printer involves the exact same pages as adding a new one, except that when you're adding a printer you make new choices and when you're modifying a printer you confirm or change existing ones.

First, click on the **Administration** tab, and then on the **Add Printer** button.

If you're only modifying an existing printer, click **Manage Printers** instead, and then choose the printer you want to modify.
Choose **Modify Printer** from the **Administration** drop-down menu.

Regardless of whether you're modifying or adding, you must enter administrative authorization before CUPS allows you to continue.
You can either log in as root, if that's available to you, or as your normal user identity, as long as you have `sudo` privileges.

Next, you're presented with a list of printer interfaces and protocols that you can use for a printer.
If your printer is plugged directly into your computer, and is on, it's listed as a *Local Printer*.
If the printer has networking built into it and is attached to a switch or router on your network, you can usually use the Internet Printing Protocol (ipp) to access it (you may have to look at your router to determine the IP address of the printer, but read your printer's documentation for details).
If the printer is a Hewlett-Packard, you may also be able to use HPLIP to access it.

Use whatever protocol makes sense for your physical setup.
If you're unsure of what to use, you can try one, attempt to print a test page, and then try a different one in the case of failure.

The next screen asks for human-friendly details about the printer.
This is mostly for your reference.
Enter a name for the printer that makes sense (I usually use the model number, but large organizations sometimes name their printers after things like fictional starships or capital cities), a description, and the location.

You may also choose to share the printer with other computers on your network.

![Sharing a printer](cups-web-ui-share.jpg)

If sharing is not currently enable, click the checkbox to enable sharing.

## Drivers

On the next screen, you must set your printer driver.
Open source drivers for printers can often be found on [openprinting.org](http://openprinting.org).
There's a good chance that you already have a valid driver, as long as you have the `gutenprint` package installed.
If the printer is a PostScript printer (many laser printers are), you may only need a PPD file from [openprinting.org](http://openprinting.org) rather than a driver.

Assuming you have drivers installed, you can choose the make (manufacturer) of your printer for a list of available drivers.
Select the appropriate driver and continue.

## Connecting to a shared printer

Now that you have successfully installed and configured your printer, you can connect to it from any other computer on your network.
For example, suppose you have a laptop, called ``client``, that you use around the house.
You want to add your shared printer to it.

On the GNOME and Plasma desktops, you can add a printer from the **Printer** screen of **Settings**.

* If you have your printer connected to a computer, then you enter the IP address of the *computer* (because the printer is access through its host).
* If you have your printer connected to a switch or router, then enter the IP address of the printer itself.

Alternately, you can keep use the CUPS interface on your client computer.
The process to access CUPS is the same: ensure CUPS is installed, open a network, and navigate to ``localhost:631``.

Once you've accessed the CUPS web interface, select the **Administration** tab.
Click the **Find New Printers** button in the **Printers** section, and then add the shared printer to your network.
You can also set the printer's IP address manually in CUPS by going through the normal **Add Printer** process.

## Print from anywhere

It's the 21st century!
Put the USB thumbdrive down, stop emailing yourself files to print from another computer, and make your printer available to your home network.
It's surprisingly easy, and supremely convenient.
And best of all, you'll look like a networking wizard to all of your house mates!