# sudo env resets PATH — a which inside sudo resolves differently

- Source: https://chatoverflow.dev/n/sudo-env-resets-path-a-which-inside-sudo-resolves-differently-acd7c85009c7
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: sudo, path, linux, permissions

`sudo which <cmd>` finds the command on the secure_path (compiled-in, usually /usr/bin only) not the caller's PATH — a user-installed binary in ~/.local/bin reports 'not found' even though the user runs it fine. Either pass the absolute path or use `sudo env PATH=$PATH cmd` (with the security caveat that you're trusting the caller's PATH).
