You are not logged in.
My PATH is
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perli know they be set with /etc/profile and /etc/profile.d/*, and this is a paragraph in /etc/profile
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
append_path '/usr/bin'when i add a new entry like
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
append_path '/usr/bin'
append_path '/test' <-------------then my PATH become
/usr/local/sbin:/usr/local/bin:/usr/bin:/test:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
^but, if i delete a entry like
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
# append_path '/usr/bin'
^ ^then my PATH have no change!!!
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
^Why does this happen?
Last edited by nibazshab (2022-10-11 13:15:59)
Offline
$ sudo grep -r -n 'PATH' /etcHmm...
/etc/login.defs:4:# Three items must be defined: MAIL_DIR, ENV_SUPATH, and ENV_PATH.
/etc/login.defs:81:# *REQUIRED* The default PATH settings, for superuser and normal users.
/etc/login.defs:84:ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
/etc/login.defs:85:ENV_PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/binlogin.defs:
#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
ENV_PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/binLast edited by Awebb (2022-10-11 11:32:54)
Offline
so, we couldn't delete /usr/local/sbin, /usr/local/bin or /usr/bin ? it is really a sad thing
oh, maybe can reset ENV_SUPATH and ENV_PATH to solve it
Last edited by nibazshab (2022-10-11 11:20:11)
Offline
i have change login.defs:
ENV_SUPATH PATH=/usr/bin
ENV_PATH PATH=/usr/binbut my PATH also have /usr/local/sbin and /usr/local/bin, i have reboot my pc, how should i do?
Offline
Look at my post again and replicate what I have done.
Last edited by Awebb (2022-10-11 11:32:31)
Offline
i do it
> grep -r -n 'PATH' /etc
...
/etc/login.defs:4:# Three items must be defined: MAIL_DIR, ENV_SUPATH, and ENV_PATH.
/etc/login.defs:81:# *REQUIRED* The default PATH settings, for superuser and normal users.
/etc/login.defs:84:ENV_SUPATH PATH=/usr/bin
/etc/login.defs:85:ENV_PATH PATH=/usr/bin> cat /etc/login.defs
...
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/bin
ENV_PATH PATH=/usr/binthere is nothing happen
Offline
sudo grep -r -n '/usr/local/bin' /etc?
Offline
this
> grep -r -n '/usr/local/bin' /etc
/etc/php/php-fpm.d/www.conf:435:;env[PATH] = /usr/local/bin:/usr/bin:/bin
/etc/security/pam_env.conf:65:#PATH DEFAULT=${HOME}/bin:/usr/local/bin:/bin\
/etc/security/pam_env.conf:66:#:/usr/bin:/usr/local/bin/X11:/usr/bin/X11
> grep -r -n '/usr/local/sbin' /etc
there is no file have /usr/local/sbin, but
> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perlLast edited by nibazshab (2022-10-11 12:04:34)
Offline
I now understand the problem:
env -i bash -c 'echo $PATH'...should output whatever BASH thinks is the default.
Offline
> env -i bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/binand, what do i need to do next ?
Offline
Also note that append_path is a function that appends something to the path. If that's not what you want to do, don't use that function. There's nothing stopping you from setting path to whatever you like ignoring any previous value. For example, if you want a broken system:
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
append_path '/usr/bin'
#append_path '/test'
PATH=/testEDIT: but see below for the concern about order of when different scripts/configs do their thing. With the above, PATH would not include any of the /usr/ paths at the end of that file. But it could be changed again later by other processes (and would need to be exported for this setting to even hold). But the point is you can set it to whatever you want wherever you want. But many such options will be a bad idea. Why do you want to remove the defaults?
Last edited by Trilby (2022-10-11 12:51:51)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Also note that append_path is a function that appends something to the path. If that's not what you want to do, don't use that function. There's nothing stopping you from setting path to whatever you like ignoring any previous value. For example, if you want a broken system:
append_path '/usr/local/sbin' append_path '/usr/local/bin' append_path '/usr/bin' #append_path '/test' PATH=/test
I didn't want to claim that, because I wasn't sure whether login.def and whereever PATH comes from otherwise doesn't happen after the profile.
> env -i bash -c 'echo $PATH' /usr/local/sbin:/usr/local/bin:/usr/binand, what do i need to do next ?
Understand, that this is the basic path that bash sets and that you cannot solve this by appending more. In addition to what Trilby says, PATH is just a variable. Nothing is stopping you from removing anything or even overwriting the whole thing. local/sbin local/bin and bin are the default, that's what bash is spiiting up on its own.
Offline
i know they be set with /etc/profile and /etc/profile.d/*, and this is a paragraph in /etc/profile
Those are *some* of the sources that can influence the $PATH
if i delete a entry like
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
# append_path '/usr/bin'
^ ^
then
You've not deleted an element from the PATH but are not adding it in this place.
my PATH have no change!!!
…
Why does this happen?
1. either the PATH wasn't reconstructed. You have to re-login to apply anything from /etc/profile, merely editing it and starting a new shell doesn't clear the environment
2. or the path is added in another location as well.
I assume this is an xy-problem and you want to remove an element form the $PATH?
1. removing "/usr/bin" from the $PATH specificially is a stupid idea, why do you think you want to do that?
2. You can remove anything from the $PATH at any time and for any context
echo ${PATH}
echo ${PATH/\/usr\/local\/sbin:/}Offline
ok thanks, I always know i can set PATH='' to setting my path, and i needn't /usr/local/bin, /usr/local/sbin, so i want to make they disappear in PATH becouse of the OCD
And I just want to know that PATH be set from system starting function, so how can i to use system starting function to set it instead of use PATH='' to cover system's setting
It's just a little personal interest
PS: re-login can change any other set path, but does not can change the three PATH /usr/loca/bin /usr/bin /usr/local/sbin, , i have relogin and reboot
Last edited by nibazshab (2022-10-11 13:06:58)
Offline
As pointed out the PATH is influenced by multiple things and as Awebb pointed out:
https://man.archlinux.org/man/core/shad … .defs.5.en
ENV_PATH (string)If set, it will be used to define the PATH environment variable when a regular user login. The value is a colon separated list of paths (for example /bin:/usr/bin) and can be preceded by PATH=. The default value is PATH=/bin:/usr/bin.
ENV_SUPATH (string)If set, it will be used to define the PATH environment variable when the superuser login. The value is a colon separated list of paths (for example /sbin:/bin:/usr/sbin:/usr/bin) and can be preceded by PATH=. The default value is PATH=/sbin:/bin:/usr/sbin:/usr/bin.
And for an unsolicited advice: don't mess around with that.
Offline
After my test, the only way is setting PATH=''
login.defs and profile can't remove "local/sbin", "local/bin"
I have no problem now
Offline