Blog Post

Modern Work App Consult Blog
3 MIN READ

Connecting a USB Printer device to WSL 2

luisdem's avatar
luisdem
Icon for Microsoft rankMicrosoft
Feb 16, 2022

 

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.

 

 

 

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

 

 

 

The setup is quick and simple:

 

 

 

 

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:

 

 

 

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:

 

 

 

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

 

usbipd wsl attach --busid 1-5
 

 

 

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

 

 

 

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:

 

 

 

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

 

lsusb

 

Notice that the printer device is listed on WSL:

 

 

 

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:

 

 

 

Click on Next to proceed:

 

 

 

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

 

 

 

Set up will configure the wireless network printer:

 

 

 

Copy the printer IP address that will be used later:

 

 

 

 

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:

 

 

 

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

 

 

 

 

Updated Nov 22, 2022
Version 7.0

2 Comments

  • -scien-'s avatar
    -scien-
    Brass Contributor

    What about connecting other usb devices to wsl? I try to connect xbox controller with no luck ☹️.

    I also posted question to wsl github page but noone answers. https://github.com/microsoft/WSL/discussions/9023

  • Johnsieo's avatar
    Johnsieo
    Copper Contributor

     

    For connecting a USB Printer device to WSL 2, you need to perform the following steps:

     

    1. Open Command Prompt in Administrator mode

     

    2. Enter “wsl –set-version Ubuntu 2” to convert Ubuntu from WSL 1 to WSL 2

     

    3. Run “wsl –list –verbose” and verify that Ubuntu is now running under WSL 2

     

    4. Navigate to the printer manufacturer website and download the latest driver for the printer model

     

    5. Open Device Manager and expand the Ports section

     

    6. If your printer has been detected, proceed to step 8; otherwise, proceed to step 7

     

    7. Connect the printer via USB; if prompted by Windows 10, select Install automatically or Install through Device Manager

     

    8. Right-click on the USB port printer entry in Device Manager and select Update Driver Software... > Browse my computer for driver software > Let me pick from a list of device drivers on my computer > Have Disk... > Browse... and navigate to the driver folder downloaded in Step 4 > OK > Next > Yes > Next > Close

     

    9. Once detected by Windows 10, right-click on its entry in Device Manager and select Properties