I'm working on a Raspberry-Pi Project: A universal easy to use print server. The goal is to plugin any USB-Printer and broadcast it to the local network.

Now, how can I add this printer automatically to cups, so I can share it with samba?

I already set up a Linux Server environment with samba and cups. I also have a script to run some code, when a usb printer has been plugged in.

The method must work with any newly connected printer, which hasn't been configured manually in any way.

  • Abandoned post by Unregistered user.
    – Milliways
    Feb 21 at 23:00

2 Answers 2


This used to be really simple, you could just use a device uri like usb:/dev/usb/lp0. Unfortunately, this has been deliberately removed. It can be enabled again by replacing just a line that signals failure with the open of the device file, but it requires a recompile of the usb backend.

If you want to avoid the recompile, you can try the parallel backend, if that doesn't work, you can always use the pipe backend. With the pipe backend you can send the print data so a simple script that essentially does cat > /dev/usb/lp0.

Then you just need a print queue assigned to that backend, and scripts called from udevd that enable and disable this queue on USB connect and disconnect. I seems you already have these scripts. Samba will automatically see the print queue if it is configured with CUPS support.

This assumes that you want to use any single printer. The printers you want to plug in should use the same control language, such as PCL.

If you want more than one printer at the same time, it is slightly more difficult, if you are interested, I can expand on that.


usb, parallel and pipe are some of the CUPS backends. The parallel backend is meant for parallel printer ports, using devices /dev/lp0to /dev/lp3. Using a device uri of parallel:/dev/usb/lp0 could work, as the device interface should be quite similar. Thepipe backend is used with a script pipe:/path/to/script. The script gets the data on stdin and can do whatever is necessary. In this case it has to send the data to /dev/usb/lp0. The pipe backend may be a SUSE extension.

To configure Samba for CUPS, you mainly have to specify printing = cups in smb.conf. See man smb.conf.

For udevd, place a file in /etc/udev/rules.d with the content

KERNEL=="lp*", ACTION=="add|remove", RUN+="/usr/local/sbin/udev-cups.sh"

The script /usr/local/sbin/udev-cups.sh can be similar to this:

case "$ACTION" in
    cupsenable "$QUEUE"
    cupsdisable "$QUEUE"
  • Nice overview about whats possible in this situation. Could you explain more on how I can use the pipe backend and how udevd works? I guess pipe is an alternative to cups, is that correct? udevd seems like a more reliable way to detect USB plug-in/out. What are the pros and cons about parallel and pipe? How do I actually configure samba to work with cups support? Sorry about that much questions Apr 19, 2019 at 15:42
  • I added some information.
    – RalfFriedl
    Apr 19, 2019 at 16:17

This solution works only if your USB printers are the same Make and Model.

  1. Open your /etc/cups/printers.conf file with your favorite text editor.

  2. Find the 'DeviceURI' line of your USB printer

    DeviceURI usb://DYMO/LabelWriter%20550%20Turbo?10238102938120938

  3. Delete the serial number including the question mark (?).

    DeviceURI usb://DYMO/LabelWriter%20550%20Turbo

Now your printers can be replaced if damaged without needing to reconfigure a new printer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.