1

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
3
  • 1
    What do you mean by “did not work”? What is the value of $PATH shown? Commented Dec 7, 2011 at 23:03
  • Which user are you logged-in as? Are you escalating to root or leveraging su or sudo?
    – ewwhite
    Commented Dec 11, 2011 at 8:30
  • I am escalating to root. Not using sudo in this case.
    – John
    Commented Dec 14, 2011 at 20:57

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .