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:

sudo: service: command not found

  • in my case, cd /sbin/; ./service gave me what I was looking for. – Greenish Aug 4 '17 at 14:07

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.

  • I think I would be better just reinstalling the whole system. Do you have an idea how the problem occured? (My last command before it happend was tmux a -t scripts and now today when I logged in I did yum install httpd and yum install php-mysql and then service httpd start, and then I could not) – user3524823 Jun 27 '14 at 21:25
  • Maybe someone broke into your server. Perhaps you were running a vulnerable PHP application. Have a look at How do I deal with a compromised server? from Server Fault. Anyway don't forget to save the logs before reinstalling for further analysis. – Cristian Ciupitu Jun 27 '14 at 21:31
  • Okay. Thanks for the help so fare. I have not ran any PHP applications. Only java jars. I dont know if they can make trouble. – user3524823 Jun 27 '14 at 21:32
  • The Java browser plugin is infamous for its security vulnerabilities, but I'm not familiar with its server side if that's your case. – Cristian Ciupitu Jun 27 '14 at 21:45

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
  • This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill Dec 26 '15 at 15:32
  • sbin should only be in the path of the root user. – Xyon Dec 26 '15 at 15:48

Your Answer

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

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