There's a little bit of background to this question - it doesn't last long but is best if I explain everything properly;

Last night I went to set up an SVN repository on my CentOS / DirectAdmin setup - I went back to my notes and went to do a 'htpasswd -cm passwd myuser'.

I was logged in as root but I got 'command not found'? This had been working a couple weeks ago, when I first set up SVN.

So I did a whereis htpasswd and found it in /usr/bin/htpasswd. I did a which htpasswd and got this:

/usr/bin/which: no htpasswd in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/admin/bin)

Strange? I did a symbolic link from /usr/bin/htpasswd and now it works. Then later I went to go 'service httpd restart', but I had the exact same problem with 'service'.

My question:

What do you think has happened? Why might these have 'disappeared'?

What is the best way to set up 'service' again so that only the users 'root' and 'admin' can use it? It exists at /sbin/service

echo $PATH

It should match what you listed above from 'which' and does not include /sbin which seems to imply you elevated your privileges but kept the environment from your normal user?

How do you login to this box usually? Are you doing 'su' or 'su -' to elevate?

If you're logging in as root directly then you want to look at your shell configuration. Probably this will be Bash so peek at ~/.bash_profile and ~/.bashrc to see if PATH is defined, if not then the system-wide defaults in /etc will apply to your session.

As a quick fix, this should work:

export PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"

All that does is add /sbin to your PATH environment variable, and it is not permanent across login sessions. You'd need to find where PATH is defined (see above) to fix for good.

  • You are spot on - thank you so much. When I last logged in, it was when I was setting the server up so I was logged in directly as root. Now I have su'd to root so yes, I needed to 'su -' rather than just 'su'. Thanks again, I'm so grateful that there are guys like you who are willing to help others out! – furnace Jun 28 '09 at 14:05
  • +1 I was having this problem today. Never knew of 'su -' but it solved the issue immediately for me too. – Sampson May 26 '10 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy