Translate

Thursday, April 12, 2018

Using custom PATH with sudo command on FreeBSD

.: Custom PATH with sudo in FreeBSD :.

In FreeBSD, the sudo command uses PATH defined by the user profile. This way, the user won't be able to find commands inside /sbin, /usr/sbin, /usr/local/sbin. If you want sudo to behavior more like its Linux version, here is how you can add a custom PATH to be used with sudo:

Add this to /usr/local/etc/sudoers.d/secure_path

Defaults secure_path = "/sbin:\
    /bin:\
    /usr/sbin:\
    /usr/bin:\
    /usr/games:\
    /usr/local/sbin:\
    /usr/local/bin:\
    /root/bin"

I hope this helps! =)
FIN