The Cookie Machine - Click here to drag window

The Cookie Machine (TCM) Future Applications:

β˜‘ View cookies used on the Pippim website.
β˜‘ Send cookie via mail. For backup or sharing.
β˜‘ Receive cookie via mail. From yourself or colleague.
β˜‘ Countdown Timers. For multi-phase time sensitive missions.
β˜‘ And in the future... Other ways of sharing/using Cookies.

If you can read me, I'm broken!

Views: 1,245β€…    Votes:  5β€…    βœ… Solution
Tags: command-line   sudo   paths  
Link: πŸ” See Original Question on Ask Ubuntu ⧉ πŸ”—


You can edit sudoers file and set secure_path to match your path. This is documented in Unix & Linux.

Is there a command line switch I can pass to sudo such that it uses the path I have set? For example:

rick@alien:~$ sudo echo $PATH
/home/rick/bin:/home/rick/.local/bin:/mnt/e/bin:/mnt/e/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ echo $PATH
/home/rick/bin:/home/rick/.local/bin:/mnt/e/bin:/mnt/e/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ sudo which auto-brightness-config
/usr/local/bin/auto-brightness-config
───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ which auto-brightness-config
/mnt/e/usr/local/bin/auto-brightness-config
───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ sudo locate auto-brightness-config
/Desktop/Link to auto-brightness-config
/home/rick/Pictures/display-auto-brightness-config 1.png
/mnt/e/Desktop/Link to auto-brightness-config
/mnt/e/usr/local/bin/.auto-brightness-config
/mnt/e/usr/local/bin/Link to auto-brightness-config
/mnt/e/usr/local/bin/auto-brightness-config
/usr/local/bin/.auto-brightness-config
/usr/local/bin/Link to auto-brightness-config
/usr/local/bin/auto-brightness-config

When I run using sudo it is finding the wrong copy of the script in /usr/local/bin when I really want the version in /mnt/e/usr/local/bin .

If I don’t want to maintain the path in sudoers file, is there a switch I can pass to sudo to use my path to find the right command?

⇧ Systemd logs (`journalctl`) are too large and slow How do I get the parent process ID of a given child process?  β‡©