0

This works:

sudo /etc/init.d/apache2 restart

It asks for my password, I enter it and apache restarts.

Then I try this:

cd /etc/init.d
sudo apache2 restart

Nope, it doesn't work. Apache displays usage info. Why can't I navigate to the directory and do the restart.

As must by now be obvious, I'm absolutely a newbie. For what it's worth I'm using Ubuntu 12.04

Emmanuel
  • 101

3 Answers3

2

If you run

sudo apache2 restart

the program apache2 is searched in the folders that the environment variable $PATH contains, not in your current working folder. So it doesn't run /etc/init.d/apache2 but /usr/sbin/apache2.

You can use

cd /etc/init.d
sudo ./apache2 restart

Here ./apache2 calls the program apache2 that is in the current working folder so you actually run /etc/init.d/apache2

0

The correct way to invoke (stop or restart or start) any service, is to give it's full path name as,

sudo /etc/init.d/apache2 restart

OR

sudo service apache2 restart
Avinash Raj
  • 78,556
0

You can put it simply by typing

sudo service apache2 restart

by the way, can you give the output when you run this command?

user3335903
  • 109
  • 3