Linux Network Printing
Dec 28, 22Setting up my HP Laserjet 1012 on my home server and configuring printing on client machines. I’ve had this printer forever, and it just keeps going. I want any device on the home network to have access to the printer.
The home server is running Arch Linux.
Install:
sudo pacman -S avahi cups hplip avahi nss-mdns
Enable Services. As root or sudo:
systemctl enable cups
systemctl start cups
systemctl enable avahi-daemon
systemctl start avahi-daemon
Configure CUPS
First, name the printer:
lpadmin -p hp_laserjet1012
Find the printer’s URI:
lpinfo -v
copy the URI, then enter it:
lpadmin -p -v [URI]
Discover the printers PPD:
lpinfo -m | less
Find the corresponding PPD file and copy it.
Set the printer’s driver, the PPD:
lpadmin -p -m [PPD]
Enable the printer:
lpadmin -p -E hp_laserjet1012
Enable sharing and remote configuration:
cupsctl –remote-admin –remote-any –share-printers
Configure Avahi
Edit the file /etc/nsswitch.conf and change the hosts line to include mdns_minimal [NOTFOUND=return] before resolve and dns
vim /etc/nsswitch.conf
hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns mdns Restart Services
systemctl restart cups
systemctl restart avahi-daemon
At this point, the printer ought to be working and shared on the network. You can set it as the default printer with:
lpadmin -d
You can print a test page from a text file like this:
lp /home/jason/textfile.txt
Set Up Clients
Depending on your setup, install requisite printing software. In my case on KDE Plasma machines running Arch Linux:
sudo pacman -S cups hplip system-config-printer print-manager
Install Avahi and set it up exactly like specified above. Enable and start/restart all the services. The printer ought to be available in the system settings and everything ought to just work.