So I can't type service on my CentOS 6.5 server.
I'm logged in as root.
When typing service I get this error:
bash: service: command not found
I have also tried to type sudo service, but with no luck.
And then I get this error:
1sudo: service: command not found
3 Answers
As discovered in the extended discussion through comments, your system is broken. I suggest reinstalling the system completely or at least the broken packages.
To have /sbin/service again run yum reinstall initscripts.
I don't recommend it, but if you want to reinstall all the packages that fail verification, run:
yum reinstall $(rpm -q --qf '%{NAME}\n' -a | while read rpm; do rpm -V $rpm >/dev/null || echo $rpm; done)Take note that even a modified configuration file or changed mtime might trigger a reinstall. Though the new configuration files should come up with the .rpmnew extension if you changed the original.
The service command resides in the sbin directory - make sure it exists at /sbin/service
If you are root, then according to this mailing list, you may need to make sure it's on your path:Centos5 - Service Command Not Present.
You may also check out a similar function called chkconfig, since it can activate services as well. CentOS - chkconfig
The links attached are for CentOS 5, but they don't seem to differ in CentOS 6.5
I was able to fix this by adding /sbin to my PATH in CentOS 5.2
export PATH=$PATH:/sbin 2