# Is there a way to apply sudo to specific serial port? Otherwise can not open

**URL:** <https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016>\
**Category:** General\
**Created:** [3 November 2022 11:51 UTC](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016 "2022-11-03T11:51:18Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 November 2022 07:59 UTC](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016/21 "2022-11-21T07:59:41Z")

</div>

You should be able to create a udev rule that either looks at the pid/vid or the serial number in order to set the port name so that it doesn’t change. Eg see [linux - How to bind USB device under a static name? - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/66901/how-to-bind-usb-device-under-a-static-name)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 November 2022 14:23 UTC](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016/22 "2022-11-21T14:23:51Z")

</div>

> [@TotallyInformation](#):
>
> If you have to resort to this, just note that the serial port will only ever change after a reboot

I think it may change if the device is unplugged and plugged back in again, or the USB bus thinks that has happened which can happen on the fly sometimes.

`udev rules` is the way to go if `serial/by-id` does not work for you. I have never had any problem with by-id though.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 November 2022 17:00 UTC](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016/23 "2022-11-21T17:00:11Z")

</div>

I found this useful when trying to use udev

> **[How To Write Udev Rules](https://hackaday.com/2009/09/18/how-to-write-udev-rules/)**
>
> Since the adoption of Kernel 2.6, Linux has used the udev system to handle devices such as USB connected peripherals. If you want to change the behavior when you plug something into a USB port, thi…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 December 2022 17:01 UTC](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016/24 "2022-12-05T17:01:01Z")

</div>

Closed on 5 December 2022 17:01 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/is-there-a-way-to-apply-sudo-to-specific-serial-port-otherwise-can-not-open/70016.md?page=1)
