Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
command not found

have you ever seen this in Redhat or Fedora ?


[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...




[anyweb@localhost anyweb]$ su
[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





[anyweb@localhost anyweb]$ su -
[root@localhost root]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:02:2D:46:B2:5F
         inet addr:  Bcast:  Mask:
         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:  Mask:
         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



[root@localhost anyweb]#


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




[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]

<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:





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








from the command prompt:


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 -.


Forum Jump:

Users browsing this thread: 1 Guest(s)