Printing: CUPS

CUPS is an open-source printing system maintained by Apple and is probably the simplest for Unix-like systems.
With CUPS, adding and sharing printers over the network becomes a fairly easy task.
Download the packages with the necessary programs and drivers.
(I only have HP printers here, but also install
gutenprint,foomatic-db,foomatic-db-engine,foomatic-db-nonfree,foomatic-filters,splix, andufr2as needed)julio@julio-acer ~ $ sudo pacman -S cups ghostscript gsfonts hpoj hplip cups-pdfIf your printer is not listed, download its PPD file from <http://www.openprinting.org/printers to /usr/share/cups/model/>
Add CUPS (
cupsd) to the daemons in/etc/rc.confDAEMONS=(syslog-ng @network netfs crond alsa httpd mysqld dbus @ntpd sshd cupsd samba @subsonic oidentd)Start the daemon and access the web interface: http://localhost:631/
Log in
- username: root
- password: same as system password
In Administration, go to “Find New Printer”. It should list the connected printers, just select them from the list.
The
cups-pdfpackage we installed earlier allows you to use a virtual printer to generate PDFs.To configure it, select:
- Device: “CUPS-PDF (Virtual PDF Printer)”
- Make/Manufacturer: Generic
- Model/Driver: Generic Cups-PDF Printer
To access the print server remotely, edit the file
/etc/cups/cupsd.confand changeListen localhost:631toport 631.To allow printing over the network, simply edit the Samba configuration file.
Printing from the command line
Use
lpstatto check available printers:julio@julio-acer ~> lpstat -p -d printer CUPS-PDF is idle. enabled since Thu 19 Jan 2012 05:47:16 PM BRST printer HP_1310 is idle. enabled since Thu 19 Jan 2012 05:50:40 PM BRST no system default destinationDefine a default printer
julio@julio-acer ~> lpoptions -d HP_psc_1310_series 1
auth-info-required=none copies=1 device-uri=hp:/usb/psc_1310_series?serial=BR5763H068O2 finishings=3 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 printer-commands=AutoConfigure,Clean,PrintSelfTestPage printer-info='HP psc 1310 series' printer-is-accepting-jobs=true printer-is-shared=false printer-location='quarto do julio' printer-make-and-model='HP PSC 1310 Series hpijs, 3.11.10' printer-state=3 printer-state-change-time=1326936293 printer-state-reasons=none printer-type=10522636 printer-uri-supported=ipp://localhost:631/printers/HP_psc_1310_series
julio@julio-acer ~> lpstat -d
system default destination: HP_psc_1310_series
- We can print a text file using the lp command.
julio@julio-acer ~> lp teste.txt
request id is HP_1310-1 (1 file(s))
- The previous print was successful, but the text came out a bit large and without margins. We can configure the paper type, margins, and other options via the command line:
julio@julio-acer ~> lp -d HP_1310 -o media=a4 -o cpi=12 -o lpi=8 -o page-left=72 -o page-top=72 teste.txt
request id is HP_1310-20 (1 file(s))
Check the manual for more options.
Printing from VIM
After a few years using VIM as my default text editor, I realized that you can do almost anything through it, including printing texts. Even codes with syntax highlighting. Unlike GVim, which has a ‘Print’ option in the File menu, printing from VIM can only be done through commands, which are worth memorizing:
- Open a text file in VIM and use the following command to print it with the default printer:
:hardcopy
The printout came out with margins and with the file name and page number in the header.
We can also use another printer, such as CUPS-PDF that we configured earlier
:set printdevice=CUPS-PDF :set printoptions=paper:A4,syntax:y,wrap:y,number:y :hardcopy
By default, CUPS-PDF saves files in /var/spool/cups-pdf/julio. To change this, edit the following
line in the file /etc/cups/cups-pdf.conf: Out /home/${USER}
Note: If printing source code, change the colorscheme to default first.
Links
- http://en.wikipedia.org/wiki/CUPS
- https://wiki.archlinux.org/index.php/CUPS
- https://wiki.archlinux.org/index.php/CUPS_printer_sharing
- http://www.cups.org/documentation.php/options.html
- http://linux.die.net/man/1/lp-cups
- http://vim.runpaint.org/basics/printing/

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.
I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.
I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.
On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.
Browse my gallery for some of my photography.
Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.
Always happy to connect! 🙂