Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-14-2001, 01:47 PM   #1
LQ Newbie
Registered: Jul 2001
Posts: 2

Rep: Reputation: 0
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.
Old 07-15-2001, 08:28 AM   #2
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596
if its executable and ure in /etc/rc.d/init.d prepend "./" , else gotta prepend the whole path.
Old 07-16-2001, 04:51 PM   #3
Registered: Jun 2001
Location: Los Angeles, CA USA
Distribution: RedHat
Posts: 53

Rep: Reputation: 15
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

Last edited by gizmola; 07-16-2001 at 04:54 PM.
Old 07-17-2001, 04:15 PM   #4
LQ Newbie
Registered: Jul 2001
Posts: 2

Original Poster
Rep: Reputation: 0

Thanks to all who replied. Now I see the light.
Old 03-13-2006, 04:51 AM   #5
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
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.
Old 03-13-2006, 08:48 AM   #6
Registered: Dec 2004
Location: Québec
Distribution: Gentoo, Kubuntu Karmic
Posts: 48

Rep: Reputation: 15
Also, in some distros like RedHat, you can modify permanently is a service starts or not at startup with
/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) :
# 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).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: command not found hamish Linux - Newbie 7 02-23-2011 04:28 PM
bash -command not found- ALInux Linux - Newbie 3 12-30-2006 12:41 PM
bash: command not found intels_ss Linux - Newbie 5 07-20-2005 07:41 PM
-bash: cp: command not found johnlittlepeap Fedora 2 11-15-2004 08:52 AM
-bash: ls: command not found jchun Linux - General 3 11-02-2004 10:11 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:36 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration