You are not logged in.

#1 2022-10-11 09:34:01

nibazshab
Member
Registered: 2022-08-25
Posts: 60

[SOLVED] How to change my the first three PATH ?

My PATH is

/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

i 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

#2 2022-10-11 10:08:21

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] How to change my the first three PATH ?

$ sudo grep -r -n 'PATH' /etc

Hmm...

/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/bin

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/local/sbin:/usr/local/bin:/usr/bin
ENV_PATH        PATH=/usr/local/sbin:/usr/local/bin:/usr/bin

Last edited by Awebb (2022-10-11 11:32:54)

Offline

#3 2022-10-11 11:17:04

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

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

#4 2022-10-11 11:30:12

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

i have change login.defs:

ENV_SUPATH      PATH=/usr/bin
ENV_PATH        PATH=/usr/bin

but my PATH also have /usr/local/sbin and /usr/local/bin, i have reboot my pc, how should i do?

Offline

#5 2022-10-11 11:30:39

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] How to change my the first three PATH ?

Look at my post again and replicate what I have done.

Last edited by Awebb (2022-10-11 11:32:31)

Offline

#6 2022-10-11 11:41:08

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

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/bin

there is nothing happen

Offline

#7 2022-10-11 11:54:35

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] How to change my the first three PATH ?

sudo grep -r -n '/usr/local/bin' /etc

?

Offline

#8 2022-10-11 12:03:52

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

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_perl

Last edited by nibazshab (2022-10-11 12:04:34)

Offline

#9 2022-10-11 12:14:51

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] How to change my the first three PATH ?

I now understand the problem:

env -i bash -c 'echo $PATH'

...should output whatever BASH thinks is the default.

Offline

#10 2022-10-11 12:19:14

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

> env -i bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/bin

and, what do i need to do next ?

Offline

#11 2022-10-11 12:30:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] How to change my the first three PATH ?

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

EDIT: 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

#12 2022-10-11 12:41:52

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] How to change my the first three PATH ?

Trilby wrote:

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.

nibazshab wrote:
> env -i bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/bin

and, 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

#13 2022-10-11 12:52:56

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,479

Re: [SOLVED] How to change my the first three PATH ?

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

#14 2022-10-11 12:53:15

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

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

#15 2022-10-11 13:22:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,479

Re: [SOLVED] How to change my the first three PATH ?

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

#16 2022-10-11 13:34:30

nibazshab
Member
Registered: 2022-08-25
Posts: 60

Re: [SOLVED] How to change my the first three PATH ?

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

Board footer

Powered by FluxBB