Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I want to disable my USB controller so after every boot, I am forced to open terminal, type Sudo -s , give password and unbind the USB.

Is there a way to automate this as a shell script without having to type the password?

I assume

Sudo -s | password | unbind string but that doesn't work.



You can configure udev to blacklist the device. https://projectgus.com/2014/09/blacklisting-a-single-usb-dev...


Yep, do this OP... don't try to hack in some automated script that now has a race condition with device setup. udev has a ton of hooks for enabling, disabling and doing anything when device state changes.


You want to use your service manager for that kind of tasks. For example, systemd or sysvinit on Linux, or launchd on macOS.


Look into NOPASSWD in the sudoers manpage. You can just put the code in a script then give %wheel (or whomever) NOPASSWD access to run it. This can also be thrown in sudoers.d for ease of copying and managing config across machines.


use an rc.local script




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: