Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am having troubles with typing commands within the terminal on some of our CentOS servers. For example, I have to include the complete and full path to the command (i.e. /sbin/chkconfig vs. chkconfig). This seems to be happening for a number of the expected locations within the system wide PATH. Some of the locations affected include:

  • /usr/sbin/
  • /usr/bin/
  • /usr/local/sbin/
  • /sbin/

I was curious how I could go about correcting this for all users (globally) on the system? I know that for scripting, I always include the full path, but when I am typing commands on the server for routine maintenance or simple troubleshooting, it would be nice to be able to type the command and have it work like it used to.

Note: I have tried this command in the past and it did not work.

echo 'export PATH=$PATH:/usr/sbin' >> $HOME/.bash_profile
. $HOME/.bash_profile
echo $PATH
share|improve this question
1  
What do you mean by “did not work”? What is the value of $PATH shown? –  Gilles Dec 7 '11 at 23:03
    
Which user are you logged-in as? Are you escalating to root or leveraging su or sudo? –  ewwhite Dec 11 '11 at 8:30
    
I am escalating to root. Not using sudo in this case. –  John Dec 14 '11 at 20:57

1 Answer 1

PATH is configured in /etc/profile, relevant files in /etc/profile.d/*, ~/.bashrc and ~/.bash_profile for bash shells and similar files for other shells.

It is not clear from your question what the exact sequence is of the commands you executed but if you modified the PATH before escalating to root that will not have any effect.

If you escalate to root to execute these commands you need to provide us the PATH when you've opened a root shell and the shell the root user is using.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.