LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash -command not found- (https://www.linuxquestions.org/questions/linux-newbie-8/bash-command-not-found-229453/)

ALInux 09-11-2004 05:22 PM

bash -command not found-
 
Hi guys
I do not know why this happens, and if anyone can help I would be thankful
The story is that sometimes when I use the bash console, I enter common and know commands and it just says "command not found" For example:

[root@localhost aliserver]# ifconfig
bash: ifconfig: command not found

Although Iam logged in as root, and although ifconfig is a common command.
Please help me guys . Iam using RH 9.0

Tinkster 09-11-2004 05:27 PM

Let me guess .. you logged in as a normal user
and then used su?

Try again, this time with "su -" ... the
- is important, otherwise you inherit the normal
users path which shouldn't have sbin in it.



Cheers,
Tink

scottman 09-11-2004 05:45 PM

It sounds like the command you are trying is not in your current
PATH. When you type a command on the prompt, bash checks
for it's file in all folders inside your PATH environmental variable.

To check your PATH

# echo $PATH

To find the location of a command

# which [command name]

Depending on your configuration, if you open a shell as a user,
then su root, your PATH will still be that of the user you su'd from.
Most users don't have access to /sbin directory's, as they contain
a lot of commands for system admin type activities. So what you
will need to do as root is add a directory to your PATH variable.

# PATH=$PATH:/sbin

This ads /sbin to the existing PATH. If you are using slackware,
you will probably want to add /usr/sbin.

# PATH=$PATH:/usr/sbin

Now bash will search those directories for the command you are
trying to use. To see the changes

# echo $PATH

Once you have figured out what directories you want to add to
you PATH, you can add these to your ~/.bashrc file to have them
executed when you enter the shell. This should also work when
you su from another user.

Hope this helps

ALInux 12-30-2006 12:41 PM

Both solutions work perfectly


Note: Iam checkin all my posts to check if there are any issues I have resolved but not posted to that other users can benefit "That is why Iam that late"


All times are GMT -5. The time now is 10:21 PM.