Connecting a USB Printer device to WSL 2
Published Feb 16 2022 06:01 AM 9,362 Views
Microsoft

 

I wrote this post to share my experience setting my HP Printer on WSL2 on Windows 11.

 

I followed the steps described at Connecting USB devices to WSL.

 

Install usbipd-win on Windows

 

The first step is download the latest release of usbip-win.

 

git01.png

 

 

Run the usbipd-win_2.1.0.msi installer and click on Install:

 

usbipd01.png

 

 

The setup is quick and simple:

 

usbipd02.png

 

 

 

Install usbipd-win on WSL 2

 

On WSL 2, I am using Ubuntu 20.04, run the following commands to install usbip:

 

sudo apt install linux-tools-5.4.0-77-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20

 

Attach your printer on USB

 

I am using a HP Deskjet 3776 printer:

 

hp3776.png

 

 

Run a command prompt on Windows as administrator, I am using Windows Terminal, and run the following command to list all the USB devices connected on Windows:

 

usbipd wsl list

 

So far, it is possible to see that I don't have any USB device attached on WSL and that the USB/IP for my printer is 1-5:

 

usbipd_cmd01.png

 

 

I run the following command to attach my printer to WSL:

 

usbipd wsl attach --busid 1-5
 

usbipd_cmd02.png

 

 

Run again the usbipd wsl list command and observe that the printer is attached to WSL:

 

usbipd_cmd03.png

 

 

As I am using Windows Terminal, I can easily split verticaly my Windows command line with Ubuntu by click on profiles and pressing Alt+Click on Ubuntu profile:

 

wslubuntu.png

 

 

Run the following command on WSL to list the USB devices:

 

lsusb

 

Notice that the printer device is listed on WSL:

 

lsusb02.png

 

 

Install CUPS (Common UNIX Printing System) on WSL

The primary mechanism for Ubuntu printing and print services is the Common UNIX Printing System (CUPS). This printing system is a freely available, portable printing layer which has become the new standard for printing in most Linux distributions. More details at CUPS - Print Server.

 

Run the following commands to install CUPS:

 

sudo apt-get update
sudo apt-get install cups –y

 

The next step is start the printer server:

 

sudo sudo /etc/init.d/cups start

 

Install HP Deskjet 3776

 

Run the following commands to download the HP setup:

 

sudo apt install hplip hplip-gui

 

Run the following command to launch the HP setup:

 

sudo hp-setup -b usb

 

On the following UI, select the third option to set up a wireless printer that requires a temporary USB connection and click Next:

 

hp01.png

 

 

Click on Next to proceed:

 

hp02.png

 

 

Observe that the USB printer is displayed in the devices list. Select the printer and click on Next:

 

hp03.png

 

 

Set up will configure the wireless network printer:

 

hp03a.png

 

 

Copy the printer IP address that will be used later:

 

hp04.png

 

 

 

Before proceeding, I just realized that I need to start the D-Bus service:

 

sudo sudo /etc/init.d/dbus start

 

Now, run the following command to finish the printer setup using the IP address provided previously:

 

sudo hp-setup 192.168.15.111

 

Here it is possible to change the default printer name in case you want. Click Add Printer to complete the setup:

 

hp05.png

 

 

That is all set. Just to test, on Chromium web browser for Ubuntu, I can see my printer and print from WSL.

 

print01.png

 

 

 

2 Comments
Co-Authors
Version history
Last update:
‎Nov 22 2022 12:27 PM
Updated by: