LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   weird command problem in linux (https://www.linuxquestions.org/questions/linux-newbie-8/weird-command-problem-in-linux-184035/)

sonesay 05-21-2004 04:54 AM

weird command problem in linux
 
I'm using rh9. sometimes i get command not found or unkonwn when i try and use commands like"service" or "ifconfig" . I dont know whats wrong . sometimes it works and then it dosent for some reason. I notice this happends at school at well. is there anyone else who has this problem?

heres it from my screen:

[ninja@P1 ninja]$ service
-bash: service: command not found

[ninja@P1 ninja]$ ifconfig
-bash: ifconfig: command not found


[ninja@P1 ninja]$ [ninja@P1 ninja]$
-bash: [ninja@P1: command not found


this is very weird .. i have no idea what is going on.

sbogus 05-21-2004 05:15 AM

Hi sonesay,

these command require (probably) root access. Try to type in su - provide the root password and then type in the commands you like.

Kind regards,
sbogus

tiger7007 05-21-2004 05:30 AM

its becouse users usally dont have access to full path's in linux thats why you need to write the full PATH for example "/sbin/ifconfig" or "/sbin/route" unless ur loging as root or editing the path's for ur user ull have to write down full path now to learn about path's just do "info path" or if u simply want to edit ur paths trough the console the command form is :
PATH=$PATH:/folder/folder1 <- to add search path as last from right
PATH=/folder/folder1:$PATH<- to add search path as last from left


*NOTE*
u might have to edit this paths as roots also the path's are being searched from the left to the right.

GoodLuck :jawa:

sonesay 05-21-2004 05:31 AM

thanks for your reply sbogus .. but I have tried those commands as root .. same problem. i used the su command to change and entered my root password. .. this is really really weird.

sonesay 05-21-2004 05:34 AM

damn i dont know whats going on.. i log in as root and the service command works now.. i dont know why it wouldnt work before. sorry if this seems like a dumb question but its been bothering me for weeks. it happends and then works fine again.

verstapp 05-21-2004 05:36 AM

However, *some* of those commands, eg ifconfig, may be used by users but live in the /sbin directory. Root gets /sbin included as part of his path, common users don't. You might try typing /sbin/<command> and seeing if that works before going the su route. Of course you will have to remember on a command-by-command basis which commands require root and which require /sbin (and which live in /bin and don't require either).

sbogus 05-21-2004 05:40 AM

Quote:

Originally posted by sonesay
thanks for your reply sbogus .. but I have tried those commands as root .. same problem. i used the su command to change and entered my root password. .. this is really really weird.
well then, try to locate where these commands are installed. As tiger7007 says, it could be that you do not have in your PATH environment the full paths to these scripts/executives.

As root, type in whereis service and see what you get as result. If you get nothing (i.e. a line like service:) then some wrong settings in the bash environment or general installation errors might be occured. Try to list each directory know to have executables in it. Try


ls -lha /bin
ls -lha /usr/bin
ls -lha /usr/sbin


and etc.
If whereis command goves you some full path to "service" then you might want to try it using the given full path.

For example
/usr/sbin/service

Kind regards,
sbogus

sonesay 05-21-2004 05:43 AM

tiger7007 your right tiger.. thanks now i know what is going on... how do i search for a particulary command location if i only konw the command name?

anandj 05-21-2004 06:55 AM

The fact that you are finding the command intermittently means that sometimes your PATH has been set and sometime it hasn't.

If you log in as
User: root
passwd:

your path would be set by your config files (.bashrc etc)

but if you log in as a user and then do 'su' it might not be scanning the root's .bashrc file.

So if you have to do 'su' then type 'su -' (su minus)
AJ

sonesay 05-21-2004 07:07 AM

cool thanks for that. its a really handy feature.


All times are GMT -5. The time now is 01:39 AM.