LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash: <command name> command not found (https://www.linuxquestions.org/questions/programming-9/bash-command-name-command-not-found-4288/)

smash 07-14-2001 01:47 PM

bash: <command name> command not found
 
I am new to running Linux. I have Mandrake 7.2. I have just put in a 3com 3c900 NIC. I want to bring it up. I edited my /etc/config.modules file to read "alias eth0 3c90x" then I navigated to /etc/rc.d/init.d/ and ran the command network restart. I got the following message: bash: network restart: command not found. I can see the executable in the directory, but when I try to run any command from the /etc/rc.d/init.d directory I get the same error. Thanks for any help.

unSpawn 07-15-2001 08:28 AM

if its executable and ure in /etc/rc.d/init.d prepend "./" , else gotta prepend the whole path.

gizmola 07-16-2001 04:51 PM

Quote:

Originally posted by unSpawn
if its executable and ure in /etc/rc.d/init.d prepend "./" , else gotta prepend the whole path.
What unspawn is pointing out, is that for security reasons, the current directory (ie. the "." that shows up in a directory listing you get from an ls -la) is not in the path. Thus any program or script you try and execute from the directory which contains that program, will not run, because the os can't find it. This is very different from DOS or NT CMD behavior. Unix basically can only find files that are in it's path, or which you explicitly specify their location in an absolute or relative way.

In order to override this behavior you can tell the shell to "look for the file in the current directory, by prepending "./" to the name. The . indicates the current directory, so basically you're specifying an explicit path to the file of current directory /somefile.

This is no different than if you were in another directory and specified the fully qualified filepath ie, you are in /etc and
type /etc/rc.d/init.d/network restart

Thus if you're in /etc/rc.d/init.d/ and want to run the network script, you should type

./network restart

smash 07-17-2001 04:15 PM

Thanks
 
Thanks to all who replied. Now I see the light.

/bin/bash 03-13-2006 04:51 AM

In the RedHat/Mandrake/Fedora/Mandriva distros you can access your services with the service command, e.g.
service network status
service network start

You don't have to supply the full path and you don't have to be in the /etc/rc.d/init.d directory.

denver1980 03-13-2006 08:48 AM

Also, in some distros like RedHat, you can modify permanently is a service starts or not at startup with
Code:

/sbin/chkconfig --list # to get all services inscribed in chkconfig and their state at each runlevel
See chkconfig's man or synopsis for more info on how to use it.

It is way easier then to make your own symbolic links in /etc/rc.d/rc[0-6].d/ !

That is why, in some scripts in /etc/init.d/, you see theses comments (this one is /etc/init.d/network) :
Code:

# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to \
#              start at boot time.

the chkconfig tells to activate this scripts in runlevel 2-3-4-5, to start it in position 10 and stop in position 90.

That is how your machine knows to start you network interface (position 10) before your database (ex : position 80) and before your web server (ex : Apache = position 90).


All times are GMT -5. The time now is 02:26 AM.