Pular para o conteúdo principal
Versão: 2.x

USB Printers on Linux

On Linux, the desktop app can't use a USB receipt printer until you allow it. You do that once, by adding one line to a rule file.

This page is for you if, on Linux, Print a test page in the desktop app ends in Nothing printed with the message The app was not allowed to reach the printer. Allow it in your system settings, then try again. Linux has no settings screen for this: the rule below is the setting.

Other signs of this problem
  • Support details, under that message, shows LIBUSB_ERROR_ACCESS.
  • In the search, your printer's card is named USB printer and a row of numbers, not the printer's own name. That usually means the app could not open the printer to read its name.
Before you start

Do this on the till itself, with this page open there, so you can copy the lines below into its terminal. Open the Terminal app (on Ubuntu and Linux Mint, press Ctrl+Alt+T). You also need the till's administrator password. If you don't have it, send this page to whoever set up the till.

Give the app the printer​

Each command below sits in a grey box. To run one, point at the box and press the copy button in its top right corner. Then click in the terminal, paste with Ctrl+Shift+V, and press Enter.

When a command asks for the password, type it and press Enter. As you type, the screen shows nothing or only stars: that is normal.

Find your printer's ids​

  1. Plug the printer in and switch it on.

  2. Find the printer's two ids. In the terminal, run:

    lsusb

    If it says command not found, install lsusb first. Each line is one USB device. Find your printer's line, for example Bus 001 Device 007: ID 04b8:0e28 Seiko Epson Corp.

    In that line:

    • Maker's id: 04b8, the code just after ID.
    • Model's id: 0e28, the code after the colon.
    • Maker's name: Seiko Epson Corp., at the end. It helps you find the line.

    If you can't tell which line is the printer, unplug it, run lsusb again, and see which line is gone.

Create and load the rule​

  1. Open a new rule file in the nano text editor:

    sudo nano /etc/udev/rules.d/99-receipt-printer.rules

    nano opens inside the terminal, with an empty page and a list of keys along the bottom. If it says command not found, install nano first.

  2. Put the rule in the file. The rule lets every account on this till use any printer with these two ids. Copy this line with the box's copy button, as before. It is longer than the box: to read it whole, point at the box (on a phone, tap it) and press the wrap button left of the copy button.

    SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0e28", MODE="0666"

    Then, in nano:

    1. Paste the rule with Ctrl+Shift+V.
    2. Replace the two ids. With the arrow keys, move to 04b8 and 0e28. Replace only those two codes with your printer's two ids, typed exactly as lsusb shows them. Keep the quotation marks around them.
    3. Check the line before you save: one line, starting SUBSYSTEM=="usb", and ending MODE="0666", with your two ids in quotation marks where 04b8 and 0e28 were.
    4. Save with Ctrl+O, then Enter.
    5. Leave nano with Ctrl+X. You are back at the terminal prompt.
    What each part of the rule means

    The rule has four parts, each but the last ending in a comma:

    • SUBSYSTEM=="usb",: the rule is for a USB device.
    • ATTRS{idVendor}=="04b8",: the maker's id.
    • ATTRS{idProduct}=="0e28",: the model's id.
    • MODE="0666": every account on this computer may use the printer, which is what a till needs.
  3. Load the rule:

    sudo udevadm control --reload-rules && sudo udevadm trigger

    If it asks for the password, type it again. When it works, it prints nothing and the prompt comes back. If it prints an error instead, stop here and see Still stuck?

  4. Unplug the printer and plug it back in.

Add the printer and test​

  1. If you saved this printer earlier with Save without testing, delete it first: in Settings → Printing, open the ⋮ menu on its row and choose Delete.
  2. In the desktop app, go to Settings → Printing and press Add printer. The search for USB printers starts by itself. Pick your printer's card, marked USB. Now that the app can open the printer, the card shows the name the printer gives itself.
  3. Press Print a test page. The panel asks Did the test page print? Answer it:
    • Yes, and it looks right: the printer is saved, and the panel says your printer's name and is set up. Press Done. The printer is ready.
    • Printed, but the ruler is off: pick the paper in your printer, and the test page prints again. See Printed, but the ruler is off.
    • Nothing came out: the panel shows Nothing printed. If it still says the app was not allowed to reach the printer, see Still not allowed, after the rule. For any other line, see Nothing came out.
Start the app as yourself

Open the desktop app the usual way, never with sudo. The rule is what lets the app use the printer as you.

If something goes wrong​

Find your symptom:

Still not allowed, after the rule​

Check, in order:

  • The two ids in the rule match lsusb exactly, lower case included.
  • The rule file holds your line. Show it with cat /etc/udev/rules.d/99-receipt-printer.rules.
  • You unplugged the printer and plugged it back in after step 5.

If all three are right, see Still stuck?. To see for yourself whether Linux applied the rule, open the check below first.

Check whether Linux applied the rule
  1. Run lsusb again, because the Device number changes each time the printer is plugged in. Note the Bus and Device numbers on the printer's line, for example Bus 001 and Device 007.

  2. Put them into this command, bus first, and run it:

    ls -l /dev/bus/usb/001/007
  3. Read the start of the line it prints:

    • crw-rw-rw-: the rule has taken effect. Press Print a test page again. If the panel still says the app was not allowed to reach the printer, see Still stuck?
    • crw-rw-r-- or crw-------: the rule has not taken effect. Go through the checklist above again, run the load command from step 5 of the setup again, then unplug the printer, plug it back in and repeat steps 1 to 3 here. If the line still starts this way, see Still stuck?
lsusb or nano: command not found

Install the missing program, then run the step again:

  • lsusb: sudo apt install usbutils on Ubuntu or Debian, sudo dnf install usbutils on Fedora.
  • nano: sudo apt install nano on Ubuntu or Debian, sudo dnf install nano on Fedora.
The card is named ttyUSB0, ttyACM0 or rfcomm0

That printer connects through a serial port, not as a USB printer, and Linux gives serial ports to the dialout group. Add yourself to it, then log out and back in:

sudo usermod -aG dialout $USER

On Arch Linux the group is uucp.

No printer found

The app lists only USB devices that say they are printers. Check the cable and that the printer is on, then press Scan again. See No printer found.

The test page prints, then later receipts don't

That is not a permission problem. Start from Still not printing?

Still stuck?​

Press Copy setup report on the Nothing printed panel, or in the ⋮ menu on the printer's row in Settings → Printing. Paste it into your message, with your printer's lsusb line and, if you ran it, the ls -l line from the check.

Why the app needs this​

Most programs print through Linux's own print system. A receipt printer needs commands sent straight to it (cut the paper, open the drawer), so the desktop app opens the printer itself.

Linux keeps USB devices for its administrator account (root) unless a rule says otherwise. The app runs as you, not as root, so without a rule it is not allowed to open the printer. The rule you added makes an exception for this one printer model.

Linux also has its own driver for USB printers, which takes hold of the printer when you plug it in. The app releases it from that driver by itself before each print, so you don't need to remove or block it. But releasing it needs the same permission as printing, which is why one rule fixes both.