Score:0

su command in /usr/bin

pt flag

I have an udev rule that runs a command as root. I have two different machines running on ubuntu and the su command in these machines are located in different locations. In one computer is located in /bin/ (ubuntu 20.04.2), while in the other is located in /usr/bin/ (ubuntu 20.10). The rule only works on the machine where su is located in /usr/bin/, even if I modify the path appropriately. How can I install su in /usr/bin/ in ubuntu 20.04.2?

The udev rule is:

ACTION=="add"\ 
, SUBSYSTEM=="bluetooth"\ 
, ATTR{idVendor}=="hci0"\ 
, ATTR{idProduct}=="3585"\ 
, RUN+="/usr/bin/su root -c 'ratbagctl M720\ Triathlon button 7 action set button 3'"
hr flag
If both systems were installed from scratch, they both should have `/bin` symlinked to `/usr/bin`, and both use `su` from `util-linux` I think. OTOH if either was upgraded (from 18.04 for example) it's possible that it is using the implementation of `su` from the `login` package.
pt flag
yes ubuntu 20.04.2 was upgraded from 18.04. I am not sure how/why ubuntu 20.10 has `su` in /usr/bin.
hr flag
This seems like it might be an XY problem - why are you using `su root` at all here, since UDEV rules presumably run as root anyhow (and if they didn't, `su` would need to run interactively, to obtain root's password)
pt flag
see the comment from nrayamajhee here https://github.com/libratbag/libratbag/issues/596
hr flag
I suspect that's a "hail mary" solution that the author doesn't really understand why it works - instead of trying to figure out the correct absolute path to `su` with the hope that the `ratbagctl` command is in the root shell's `PATH`, I'd suggest giving an absolute path to `ratbagctl` directly i.e. something like `RUN+=/usr/local/bin/ratbagctl Logitech\ MX\ Anywhere\ 2S dpi set 2400`
pt flag
it doesnt work like this `ACTION=="add", SUBSYSTEM=="bluetooth", ATTR{idVendor}=="hci0", ATTR{idProduct}=="3585", RUN+="/usr/bin/ratbagctl M720\ Triathlon button 7 action set button 3"`I remember that last time it took me a while to make the udev rule to work (and the final rule that worked is that I posted above).
pt flag
for some reason the udev rule is not being triggered. So at this point the problem is not necessarily the run command (I have replace the run command for another one that writes a time stamp, and it is not working neither)
hr flag
OK so make sure you also give the full path to whatever command writes the timestamp - as noted in `man udev` *If no absolute path is given, the program is expected to live in /lib/udev; otherwise, the absolute path must be specified.*. Apologies for omitting the quotes above, you are correct it should be `RUN+="/path/to/command args"`. Check where `ratbagctl` is actually located with `which ratbagctl` and/or `type -a ratbagctl`.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.