Skip to content

Instantly share code, notes, and snippets.

@jaindinkar
Forked from Solarflame5/cups_hplj1020_tutorial.md
Last active April 23, 2026 12:12
Show Gist options
  • Select an option

  • Save jaindinkar/da301afbd06b67f0ac1e43d636c43dd6 to your computer and use it in GitHub Desktop.

Select an option

Save jaindinkar/da301afbd06b67f0ac1e43d636c43dd6 to your computer and use it in GitHub Desktop.
How to set up an HP LaserJet 1020 printer server using CUPS on Raspberry Pi OS Bullseye

How to set up an HP LaserJet 1020 printer server using CUPS on Raspberry Pi OS Bullseye

Set up the Raspberry Pi

Note: This probably also works in Raspberry Pi OS Bookworm, but I have only tested this on my Pi 1 B+ that doesn't support Bookworm. It should also probably work on most Debian based distros including Ubuntu.

  • Additional Note: Tested this on RPi Zero 2 W with RPi OS Lite (64bit) and it works like charm.
  • Flash the Raspbian Bullseye Lite image to the SD card
  • Configure the user account, network and SSH settings while imaging to make setup easier.

Install the required packages

You need to install CUPS, HPLIP, and the foo2zjs printer drivers, use the following commands:

sudo apt update
sudo apt install cups hplip printer-driver-foo2zjs

CUPS will handle managing printers and sharing them to your network, HPLIP is required to upload the printer firmware to the printer, and the foo2zjs drivers are required for printing.

Set up CUPS

Run the following commands to allow configuring CUPS without logging in as root and from other computers in the network:

sudo usermod -a -G lpadmin [your username]
sudo cupsctl --share-printers --remote-any
sudo lpadmin -p [printer-name] -o printer-is-shared=true
(optional: adds auth) sudo lpadmin -p printer -o printer-op-policy=authenticated
sudo systemctl restart cups

Set up the HP Plugin

The HP LaserJet 1020 requires its firmware to be uploaded everytime its connected, HPLIP handles this automatically after setting it up. Plug in your printer, turn it on, and then run the following command:

sudo hp-plugin -i

Then follow these steps:

  1. Choose "Download plug-in from HP (recommended)"
  2. Accept the license terms for the plugin
  3. Wait for it to install

Configure your printer in CUPS

  1. Open the web interface for CUPS by navigating to https://[Your pi's IP]:631(https://192.168.1.17:631 for example)
  2. Click "Administration" in the top navigation bar
  3. Click the "Add printer" button under Printers (if it doesn't show the connections page in next tab it's good, if it shows it, choose "Administration" again and this time choose "Find my printer" you will find your printer name there.
  4. Select "HP LaserJet 1020 USB FN2Z0GV HPLIP (HP LaserJet 1020)" under "Local Printers"
  5. Check "Share this printer" to use it across the network.
  6. At this point make sure the name of your printer does not contain any spaces, hyphens or underscores. Just alphanumeric.
  7. Click "Continue"
  8. Select "HP LaserJet 1020 Foomatic/f002zjs-z1 (recommended) (en)" under the printer model, make sure that the make is "HP"
  9. Click "Add printer"
  10. Click "Set default options"

Now you need to set the postscript renderer to ghostscript in cups-filters, run the following command in the terminal using your printer's name("HP_LaserJet_1020" for example):

lpadmin -p [your printer's name in CUPS] -o pdftops-renderer-default=gs

Test the printer

Go back to the CUPS web interface, and navigate to your printer's page, click the "Maintenance" drop down and click "Print test page", you have successfully set up your printer if it prints without any problems.

Adding the printer to Ubuntu:

run this command: sudo lpadmin -p LaserJet -E -v [cups printer address] example printer address: http://192.168.1.9:631/printers/HPPrinter

  • Make sure to use the IP address and name of the printer correct.

Additional Notes:

  • use systemctl cups restart (often as often as you can)
  • use systemctl cups status (to check for the service status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment