[SOLVED]Cannot set $PATH variable

Need help with C, C++, perl, python, etc?

[SOLVED]Cannot set $PATH variable

Postby pthfdr » 2016-09-20 05:37

It seems that some programs are overriding my $PATH settings in /etc/profile.
All the shell configurations are done in /etc/profile and /etc/bash.bashrc.I have no ".profile" and ".bashrc" in mine and root's $HOME.
Code: Select all
6677,0,0>pthfdr@SALAMAND:~$ mkfs.fat --help
bash: mkfs.fat: command not found
6678,127,0>pthfdr@SALAMAND:~$ which mkfs.fat
6679,1,0>pthfdr@SALAMAND:~$ sudo which mkfs.fat
/sbin/mkfs.fat
6680,0,0>pthfdr@SALAMAND:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games
6681,0,0>pthfdr@SALAMAND:~$ sudo echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games
6682,0,0>pthfdr@SALAMAND:~$ su
Password:
204,0,0>root@SALAMAND:/home/pthfdr# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
205,0,0>root@SALAMAND:/home/pthfdr# cat /etc/profile|grep PATH
# SET PATH
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
export PATH
206,0,0>root@SALAMAND:/home/pthfdr# cat /etc/bash.bashrc|grep PATH
207,1,0>root@SALAMAND:/home/pthfdr#
Last edited by pthfdr on 2016-09-20 08:57, edited 1 time in total.
pthfdr
 
Posts: 17
Joined: 2015-07-19 08:18

Re: Cannot set $PATH variable

Postby debiman » 2016-09-20 06:07

i have noticed the discrepancy between "sudo echo $PATH" and "sudo which mkfs.fat", but i think this is how it's supposed to be.
in fact, your whole output looks pretty sane and i can fully reproduce it on my debian system.
User avatar
debiman
 
Posts: 1545
Joined: 2013-03-12 07:18

Re: Cannot set $PATH variable

Postby ralph.ronnquist » 2016-09-20 06:34

You do realize that $PATH is expanded before sudo is invoked?
You might instead want to use
Code: Select all
sudo env | grep -w PATH
or
Code: Select all
sudo bash -c 'echo $PATH'
to review $PATH for root.
User avatar
ralph.ronnquist
 
Posts: 308
Joined: 2015-12-19 01:07
Location: Melbourne, Australia

Re: Cannot set $PATH variable

Postby pthfdr » 2016-09-20 08:35

I have shown that in the code.
The problem is that I have set the global $PATH in /etc/profile (and nowhere else) and everyone's $PATH should be the same.
pthfdr
 
Posts: 17
Joined: 2015-07-19 08:18

Re: Cannot set $PATH variable

Postby ralph.ronnquist » 2016-09-20 08:51

Ah, yes. I didn't scroll down, did I?
Anyhow, have you looked into /etc/login.defs ? I have a memory of having to go there to get /sbin into my path.
User avatar
ralph.ronnquist
 
Posts: 308
Joined: 2015-12-19 01:07
Location: Melbourne, Australia

Re: Cannot set $PATH variable

Postby pthfdr » 2016-09-20 08:56

Okay,okay.I surrender.
pthfdr
 
Posts: 17
Joined: 2015-07-19 08:18

Re: Cannot set $PATH variable

Postby debiman » 2016-09-20 17:12

pthfdr wrote:The problem is that I have set the global $PATH in /etc/profile (and nowhere else) and everyone's $PATH should be the same.

no it shouldn't.
pthfdr wrote:Okay,okay.I surrender.

yes you should.
User avatar
debiman
 
Posts: 1545
Joined: 2013-03-12 07:18


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable