Skip to content

Use root PATH for sudo on FreeBSD

  1. sudo vi /usr/local/etc/sudoers.d/secure_path

  2. Enter this text on one line (changing the value as desired):

    Defaults secure_path = "/usr/local/share/pcbsd/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin"
  3. Save the file

For more information see the sudoers man page. Note, however, that there are good reasons to keep the invoking user’s PATH.