How to Set Up a Print Server on Raspberry Pi Using CUPS and Ubuntu 20.04
3 min readAug 22, 2020
What You Need
- Raspberry Pi with Wi-Fi and an 8GB+ micro SD.
- Raspberry Pi Imager. Get it from https://www.raspberrypi.org/downloads/
- An old printer. I have an old HP Officejet 5610 All-in-One Printer from 2001
Steps
1. Install
- Open Raspberry Pi Imager and install Ubuntu on the SD Card
- Connect the keyboard and the monitor to the Raspberry Pi and start it.
Default username: ubuntu, password: ubuntu. It worked after multiple (5 or 6) failed attempts.
2. Setup WiFi
- Open config file
# find the wireless network interface (e.g. wlan0)
ls /sys/class/net# find the config file (e.g. 50-cloud-init.yaml)
ls /etc/netplan/# open config file
sudo nano /etc/netplan/50-cloud-init.yaml
- Add the wifi config (using 4 spaces not tabs)
- Save and exit
- Reboot or apply
sudo netplan apply
3. Update and enable SSH
sudo apt update
sudo apt upgradesudo apt install -y wireless-tools net-toolssudo service ssh enable
sudo service ssh startifconfig
landscape-sysinfo
- Get the wlan0 ip
- SHH should be installed, but if not, can be configured from here https://pimylifeup.com/ubuntu-server-raspberry-pi/
4. SSH into the Raspberry
ssh ubuntu@192.168.10.50
5. Install CUPS
- Paste in the terminal
sudo apt install -y cups hplip printer-driver-gutenprint && \
sudo systemctl start cups && \
sudo systemctl enable cups && \
sudo usermod -a -G lpadmin ubuntu && \
systemctl status cups && \
sudo nano /etc/cups/cupsd.conf
- Add or modify
this
Browsing Off
Listen localhost:631....<Location />
Order allow,deny
</Location>....<Location />
Order allow,deny
</Location>
to
Browsing On
Port 631....<Location />
Order allow,deny
Allow @LOCAL
</Location>....<Location /admin>
Order allow,deny
Allow @LOCAL
</Location>
- Save and exit
- Connect the printer to the USB port of the Raspberry Pi
- Restart service and allow clients in firewall. My private network is using the 192.168.10.0 ~192.168.10.255 network range
sudo systemctl restart cups
sudo ufw allow in from 192.168.10.0/24 to any port 631
6. Add printer
- Go to https://192.168.10.50:631/admin
- Use the ubuntu username and the new password configured for Raspberry Pi
- Add the printer by selecting the model
- Check the Printers tab
7. Testing the printer
Printer now should be available on the network.
AirPrint is Apple’s wireless printing technology, letting you print from any Apple device to a machine that is AirPrint compatible.