I was perusing various forums this evening in an effort to gather some good fodder for future Command Line articles when I stumbled upon a thread that immediately piqued my interest. The subject in question was how to print from a particular app that was running on Chrome OS via the Linux container. It occurred to met that, as much as I tinker with Crostini, I have never attempted to print from an installed Linux application. So, I fired up Libre Office to see what I could find. When trying to print from Libre Office on my Pixelbook Go, I was presented only with the option of a “generic printer” and no way to add a new one. As reported in the forum post I found, the container that runs the Linux app did not have access to the printers currently in use by the Chrome OS side of my Chromebook.
This wasn’t much of a surprise but it led me to begin digging for a solution to this problem. With more and more people using Linux apps on Chrome OS, the ability to print from Crostini is a must-have, in my opinion. What good are apps like Libre Office if you can’t print your work? Sure, you could save to your Linux folder then open your file in Chrome and print that way but that feels so hacky. Besides, what’s the fun in that? After a little research and slightly more tinkering, I discovered that I could set up my HP Deskjet 2652 printer inside my Linux container using CUPS and a couple of simple commands in the Linux terminal.
What is CUPS? I’ll let the official CUPS website do the explaining on this one.
CUPS is the software you use to print from applications like the web browser you are using to read this page. It converts the page descriptions produced by your application (put a paragraph here, draw a line there, and so forth) into something your printer can understand and then sends the information to the printer for printing.cups.org
CUPS printing works with Debian-based systems and is easily installed on Linux-enabled Chromebooks with a simple terminal command. Combined with a printer configuration tool, you can set up an HP printer (and likely most network printers) using in a matter of minutes. To give it a try, you will first need to make sure that your Chromebook is up-to-date and Linux is enabled. Learn how here. Next, you will want to make sure that your wireless printer is on and connected to your home network. Now we will install the necessary tools and launch the printer configuration tool. From the Linux terminal, run the following commands one at at time.
sudo apt install cups sudo apt install system-config-printer xhost + sudo system-config-printer
Once you run the last command, you should be greeted with a GUI for adding a new printer. When you click “add,” it may take a moment to find your printer but when it does, it will populate in the left-hand menu. Select your printer and click the “forward” button to complete the installation process. Once complete, you can print a test page to make sure everything is working and now your printer should show up when you try to print from Linux applications. For additional options for HP printers, you can install the HP Linux Imaging package but I found that it wasn’t needed for my printer. If you find that you need it, you can install the package by running the following command in the terminal.
sudo apt install hplip
I will test this on other printer brands in the coming weeks and we will also explore other methods to set up printers for Linux on Chrome OS but this method is quick and simple. One more reason why I think HP printers are the best option for Chromebook users. They just work and that a good thing.
UPDATE: I got to the office and tried out the printer config tool and it immediately recognized every printer on the office network.