Linux-Noob Forums

Full Version: command not found
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

have you ever seen this in Redhat or Fedora ?

 



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




 

the reason... even though you are logged in as root, is because of the WAY you logged in.

 

let's look at the way i logged in by seeing the whole picture...

 

 

 



Code:
[anyweb@localhost anyweb]$ su
Password:
[root@localhost anyweb]# ifconfig
bash: ifconfig: command not found
[root@localhost anyweb]#




 

i logged in to root by using su, now that does make me root, but it doesnt give me root's path to all the lovely things root normally has access to..... which explains the errors above.

 

So, to get root and roots path simply do like this

 

 

 

 



Code:
[anyweb@localhost anyweb]$ su -
Password:
[root@localhost root]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:02:2D:46:B2:5F
         inet addr:192.168.0.117  Bcast:192.168.0.255  Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:181014 errors:0 dropped:0 overruns:0 frame:0
         TX packets:173787 errors:322 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:86004986 (82.0 Mb)  TX bytes:25431537 (24.2 Mb)
         Interrupt:11 Base address:0x100
                                                                               
lo        Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:2598 errors:0 dropped:0 overruns:0 frame:0
         TX packets:2598 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:1777456 (1.6 Mb)  TX bytes:1777456 (1.6 Mb)

[root@localhost root]#




 

notice now, that ifconfig WORKS.

 

while we are here, look at the first bit of code again, when i logged in as su (without the DASH) root was labelled as

 

 



Code:
[root@localhost anyweb]#




 

but after logging in as su - root is now labelled as

 

 

 



Code:
[root@localhost root]#




 

see the difference ?

 

for more info.. about why this happens have a look at this live chat on IRC i had...

 

Quote:<anyweb> is the su - phenonemon only common to redhat/fedora or all linux ? as in command not found when su versus su ---- TH0R sets channel limit to 200

<hardly_ev> as far my experience proves it "su -" is distribution independent ;)

<|SyKo|> hehaeh never heard of a "su - " phenomenon

<slackmin> i believe you need to adjust your PATH variable

<hardly_ev> however it depends on envirnoment setup

<slackmin> yes look at your .login .loginsh and so on

<anyweb> in redhat and fedora su and su - make a big difference

<anyweb> as in > [/url][url=<___base_url___>/index.php?showtopic=549][/url][url=<___base_url___>/index.php?showtopic=549]https://www.linux-noob.com/forums/index.php?showtopic=549

<anyweb> so i was just wondering is it only those distros, or do others also have this problem

<crib> read the su manpage.

<hardly_ev> anyweb: the - makes su execute .login .loginrc and so on for the user you "su" into

<hardly_ev> anyweb: as crib said read the mans ;)

<crib> typing only 'su' will not load the environment of the user you are changing to. it will merely substitute your UID and GID.

<ducch> anyweb thats 31337~

<anyweb> thats not my question tho, my question is how many distros are affected the same way

<hardly_ev> anyweb: su works the same way on most of the distros

<anyweb> so do most distros also need the - hardly_ev ?

<hardly_ev> anyweb: yep... su behaves the same way in almost any distro I worked with

You can also do this instead of logging in as root:



Code:
/sbin/ifconfig





yup

 

but the idea of this topic, is to explain to da noobs why they are getting 'command not found' while logged in as root

 

:)

 

cheers

 

anyweb


from the command prompt:

 



Code:
danZenie@localhost># echo "alias su='su -'">>~/.bashrc
danZenie@localhost># source ~/.bashrc




 

this will do if you're a bash user. and most likely if you're on a fedora or RH box then you are a bash user. no more worries about su and su -.