Sujet : Re: Default PATH setting - reduce to something more sensible?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shellDate : 20. Jan 2025, 09:46:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vml2ho$30d8f$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 20.01.2025 09:05, Wayne wrote:
On 1/14/2025 8:55 AM, Dan Cross wrote:
... It seems to me that, as a normal user, the PATH
(and with it the path-search) could be drastically reduced. Is there
a method to only have them in the PATH when 'sudo'ing any programs
that require root privileges and the privileged programs in 'sbin'?
>
Yes, `sudo` can be configured to set $PATH for the programs that
it invokes; see sudoers(5) and look for `secure_path`. If you
don't invoke those from your normal shell, I don't see a problem
removing them from the default.
As for non-sudo PATH, you can always run:
export PATH=$(getconf PATH)
To get a minimal PATH setting guaranteed to include all POSIX
utilities.
Yes, this comes very close to what I was actually aiming at. In
my environment that's just /bin and /usr/bin and this is what I
typically need in my scripts (plus sometimes /usr/local/bin).
(For interactive use I'd add that too, and also my ~/bin, e.g.)
But all the sbin directories (and other clutter) would be gone.
It practically shows that these directories are unnecessary for
a normal (non-root) user. - Good hint. Thanks.
Janis