Linux: apachectl - Command not found

CrackaLackaZe

Senior member
Jun 29, 2002
922
0
76
I can see both httpd and apachectl right there in the directory with my own two eyes. But it keeps giving me a "command not found" message when I try to run it. I've tried ./apachectl and /usr/local/apache2/apachectl and I get the same thing. It used to work before. I'm not sure what happened. The server is running and I need to restart it. Anyone know whats up?
 

CrackaLackaZe

Senior member
Jun 29, 2002
922
0
76
Actually, correction.../usr/local/apache2/bin/apachectl works, but why doesn't just typing apachectl from the directory work? How do I fix my path setting?
 

Netopia

Diamond Member
Oct 9, 1999
4,793
4
81
If you want to make something run in a directory that isn't in your path, try putting a ./ before the command. ie... ./apachectl

Joe
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: Netopia
If you want to make something run in a directory that isn't in your path, try putting a ./ before the command. ie... ./apachectl
Not always. That only works if the executable is in your current directory. The "./" means "current directory".

If you want to change your path, you can do so in your shell startup files. Different distros sometimes handle this in slightly different ways, but it should pretty much always work to add the following line to /home/username/.bashrc:

export PATH="$PATH:/path/to/dir/you/want"

Log out (or close the xterm), and log back in (or open a new xterm) and try echo $PATH to see if your changes worked. If it didn't, try editing /home/username/.bash_profile instead.



 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
An alternate solution: put a link in /usr/bin to the apachectl executable. That'd keep your path from getting bloated
 

CrackaLackaZe

Senior member
Jun 29, 2002
922
0
76
ok, now for every file that exists in my current directory, I have to type ./[command] to get it to run. How do I make it so all I have to do is type the command from within the directory?
 

CrackaLackaZe

Senior member
Jun 29, 2002
922
0
76
Nevermind, I'll just use the "su -" command, and I know what cleverhandle's saying will fix it but I'm not sure I understand how to execute those instructions.
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: CrackaLackaZe
Nevermind, I'll just use the "su -" command, and I know what cleverhandle's saying will fix it but I'm not sure I understand how to execute those instructions.
Thousands of people before you have been able to change their $PATH... and so can you.

But seriously, if you're going to run a server you really need to understand things like $PATH's, environment variables, and editing config files. If my quick and dirty explanation isn't detailed enough, then search around online for something like "linux command line basics" and find something that suits your temperament better. It's not rocket surgery...
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
generally, you don't want "." to be part of your path because you may end up in some directory that has an executable of the same name as a command that you intended to use and you end up running the wrong thing. many people say that you should always spell out the full path of all executables you run as root to ensure that something like that doesn't happen, but i also know that many people get lazy with that sort of thing.