Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED]Cannot set $PATH variable

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
pthfdr
Posts: 17
Joined: 2015-07-19 08:18

[SOLVED]Cannot set $PATH variable

#1 Post by pthfdr »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Cannot set $PATH variable

#2 Post by debiman »

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
ralph.ronnquist
Posts: 342
Joined: 2015-12-19 01:07
Location: Melbourne, Australia
Been thanked: 6 times

Re: Cannot set $PATH variable

#3 Post by ralph.ronnquist »

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.

pthfdr
Posts: 17
Joined: 2015-07-19 08:18

Re: Cannot set $PATH variable

#4 Post by pthfdr »

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.

User avatar
ralph.ronnquist
Posts: 342
Joined: 2015-12-19 01:07
Location: Melbourne, Australia
Been thanked: 6 times

Re: Cannot set $PATH variable

#5 Post by ralph.ronnquist »

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.

pthfdr
Posts: 17
Joined: 2015-07-19 08:18

Re: Cannot set $PATH variable

#6 Post by pthfdr »

Okay,okay.I surrender.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Cannot set $PATH variable

#7 Post by debiman »

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.

Post Reply