Centos – “service” command not found, “htpasswd” command not found ..

centos

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

Best Answer

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.

Related Topic