LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ifconfig not working as expected... (https://www.linuxquestions.org/questions/linux-newbie-8/ifconfig-not-working-as-expected-827007/)

sheykh 08-18-2010 09:15 AM

ifconfig not working as expected...
 
(Sorry if my RE is a little vague, unsure how else to word this!)

So I've finally settled on CentOS. Stable (AFAIK), looks good, and easy enough, yet not too easy enough. Make sense? Heh...

Well, up until a couple of days ago, ifconfig stopped working for me. Rather.... That command alone gives me the bash: ifconfig: command not found response. However... When I enter in /sbin/ifconfig command, it works fine.

Now, thanks to my friend Google, I know that ifconfig resides in that directory. I know that I can run with the /sbin/ in front of the command, and I can go on my merry way, and live the rest of my life underneath my umbrella of content. But lets be honest. I want it back! Heh

So I'm not sure what else I can give you so that you can just say, "Oh do this, that, and bodaboombadabing, you are back in business!". And all I can speculate, is that something happened to the 'link?' or whatever got debunked. So.... Ok. I'm ranting now. TIA!!!!

=D

sem007 08-18-2010 09:24 AM

Check /sbin dir listed in your path variable


provide output of below command

Code:

echo $USER
echo $PATH


sheykh 08-18-2010 09:38 AM

Code:

[shaun@localhost sbin]$ ls
accton                  ip                            multipath.static
addpart                ip6tables                      nameif
adsl-connect            ip6tables-restore              nash
adsl-setup              ip6tables-save                netplugd
adsl-start              ipmaddr                        netreport
adsl-status            ipppstats                      new-kernel-pkg
adsl-stop              iprofd                        nologin
agetty                  iptables                      pam_console_apply
alsactl                iptables-restore              pam_tally
arp                    iptables-save                  pam_tally2
arping                  iptunnel                      pam_timestamp_check
audispd                isdnctrl                      parted
auditctl                isdnlog                        partprobe
auditd                  iwconfig                      partx
aureport                iwevent                        pcbitctl
ausearch                iwgetid                        pccardctl
autrace                iwlist                        pcmcia-check-broken-cis
avmcapictrl            iwpriv                        pcmcia-socket-startup
badblocks              iwspy                          pidof
blkid                  kdump                          pivot_root
blockdev                kexec                          plipconfig
busybox                killall5                      portmap
capiinit                klogd                          poweroff
cbq                    kpartx                        pppoe
cciss_id                kpartx.static                  pppoe-relay
change_console          kudzu                          pppoe-server
chkconfig              ldconfig                      pppoe-sniff
clock                  logsave                        ppp-watch
consoletype            loopctrl                      pvscan
cryptsetup              losetup                        quotacheck
ctrlaltdel              lsmod                          quotaoff
debugfs                lspci                          quotaon
delpart                lspcmcia                      rdisc
depmod                  lsusb                          rdump
dhclient                lvm                            rdump.static
dhclient-script        lvm.static                    reboot
dhcp6c                  MAKEDEV                        request-key
dm_dso_reg_tool        makedumpfile                  resize2fs
dmeventd                mcstransd                      restore
dmevent_tool            mdadm                          restorecon
dmraid                  mdadm.static                  restore.static
dmraid.static          mdassemble.static              rmmod
dmsetup                mdmpd                          rmt
dmsetup.static          mgetty                        rngd
dosfsck                microcode_ctl                  route
dosfslabel              mii-diag                      rpc.lockd
dump                    mii-tool                      rpc.statd
dumpe2fs                mingetty                      rrestore
dump.static            mkbootdisk                    rrestore.static
e2fsck                  mkdosfs                        rtmon
e2image                mkdumprd                      runlevel
e2label                mke2fs                        runuser
ether-wake              mkfs                          salsa
ethtool                mkfs.cramfs                    scsi_id
extlinux                mkfs.ext2                      service
fdisk                  mkfs.ext3                      setfiles
findfs                  mkfs.msdos                    setkey
firmware_helper        mkfs.vfat                      setpci
fixfiles                mkinitrd                      setsysfont
fsck                    mkswap                        sfdisk
fsck.cramfs            mkzonedb                      sgpio
fsck.ext2              modinfo                        shutdown
fsck.ext3              modprobe                      slattach
fsck.msdos              mount.cifs                    sln
fsck.vfat              mount.ecryptfs                start_udev
fstab-decode            mount.ecryptfs_private        sulogin
fuser                  mount.nfs                      swapoff
generate-modprobe.conf  mount.nfs4                    swapon
genhostid              mount.vmhgfs                  sysctl
getkey                  mpath_ctl                      syslogd
grub                    mpath_prio_alua                tc
grubby                  mpath_prio_alua.static        telinit
grub-install            mpath_prio_emc                tune2fs
grub-md5-crypt          mpath_prio_emc.static          udevcontrol
grub-terminfo          mpath_prio_hds_modular        udevd
halt                    mpath_prio_hds_modular.static  udevd.static
hdparm                  mpath_prio_hp_sw              udevsettle
hisaxctrl              mpath_prio_hp_sw.static        udevtrigger
hwclock                mpath_prio_intel              umount.cifs
ibod                    mpath_prio_intel.static        umount.ecryptfs
icnctrl                mpath_prio_netapp              umount.ecryptfs_private
ifcfg                  mpath_prio_netapp.static      umount.nfs
ifconfig                mpath_prio_ontap              umount.nfs4
ifdown                  mpath_prio_ontap.static        unix_chkpwd
ifenslave              mpath_prio_rdac                unix_update
ifrename                mpath_prio_rdac.static        update-pciids
ifup                    mpath_prio_tpc                vboxd
init                    mpath_prio_tpc.static          vconfig
initlog                mpath_prio_weighted            vgchange
insmod                  mpath_prio_weighted.static    vgscan
insmod.static          mpath_wait                    weak-modules
install-info            multipath                      ypbind


[shaun@localhost sbin]$ echo $USER
shaun


[shaun@localhost sbin]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin

This what you need? =D Thank you by the way!!!!!

sem007 08-18-2010 09:45 AM

Quote:

This what you need? =D Thank you by the way!!!!!
nope dear..

Any way you are loging through non-root user. /sbin dir not listed in non-root user's PATH.

only root or privileged users can run commands of /sbin /usr/sbin and /usr/local/sbin

run below command to verify your path

Code:

for non-root user
$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/u1/bin

root user
# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin


repo 08-18-2010 09:52 AM

You can execute ifconfig as a user, if you provide the whole path
Code:

/sbin/ifconfig

sheykh 08-18-2010 10:07 AM

Code:

[root@localhost /]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[root@localhost /]# ifconfig
bash: ifconfig: command not found

Sorry. Thought I was root. Still learning... ;]~ But as so far... I cannot wait to get my new lappy, and straight out of the door, running CentOS, instead of bowing down to WIN7!!! LoL! TIA everyone! =]

sem007 08-18-2010 10:13 AM

Quote:

Originally Posted by sheykh (Post 4070314)
Code:

[root@localhost /]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[root@localhost /]# ifconfig
bash: ifconfig: command not found

Sorry. Thought I was root. Still learning... ;]~ But as so far... I cannot wait to get my new lappy, and straight out of the door, running CentOS, instead of bowing down to WIN7!!! LoL! TIA everyone! =]

# prompt display on your screen but i am sure you are login as non-root user.
Quote:

/home/shaun/bin
you are login as shaun user Am i right?

if yes then you have to give full path of command.

Code:

/sbin/ifconfig

sheykh 08-18-2010 10:18 AM

Code:

[shaun@localhost ~]$ echo $USER
shaun
[shaun@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[shaun@localhost ~]$ su
Password:
[root@localhost shaun]# echo $USER
shaun
[root@localhost shaun]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[root@localhost shaun]#

Yes... I am logged in with my user account shaun (Yea, my real name, hello btw!! LoL!) and then I su to get to root.... So if I am doing something wrong, or not doing it the 'right' way. Please lemme know. Again.... NOOB!!!!! su is all I've learned... So far. *evil grin*

sem007 08-18-2010 10:23 AM

Quote:

Originally Posted by sheykh (Post 4070334)
Code:

[shaun@localhost ~]$ echo $USER
shaun
[shaun@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[shaun@localhost ~]$ su
Password:
[root@localhost shaun]# echo $USER
shaun
[root@localhost shaun]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/shaun/bin
[root@localhost shaun]#

Yes... I am logged in with my user account shaun (Yea, my real name, hello btw!! LoL!) and then I su to get to root.... So if I am doing something wrong, or not doing it the 'right' way. Please lemme know. Again.... NOOB!!!!! su is all I've learned... So far. *evil grin*

hi shaun:)

if you want to become root just run su command as below

Code:

$ su -
or
$ su - root

and then check your PATH

Code:

echo $PATH

sheykh 08-18-2010 10:40 AM

Code:

[root@localhost shaun ~]# su - root
[root@localhost ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

HI! =]

That what you need now? I see :/sbin/: in the $PATH. So, shouldn't su then ifconfig be working? *tear*

sem007 08-18-2010 10:47 AM

Quote:

Originally Posted by sheykh (Post 4070363)
Code:

[root@localhost shaun ~]# su - root
[root@localhost ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

HI! =]

That what you need now? I see :/sbin/: in the $PATH. So, shouldn't su then ifconfig be working? *tear*

ok now run ifconfig at shell and see what happen

Code:

# ifconfig

sheykh 08-18-2010 10:53 AM

almost....there.....
 
Code:

[shaun@localhost ~]$ ifconfig
bash: ifconfig: command not found
[shaun@localhost ~]$ su
Password:
[root@localhost shaun]# ifconfig
bash: ifconfig: command not found
[root@localhost shaun]# su - root
[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4F:05:CC
          inet addr:10.11.8.22  Bcast:10.11.8.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:5cc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:581004 errors:0 dropped:0 overruns:0 frame:0
          TX packets:388944 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:524565816 (500.2 MiB)  TX bytes:306291525 (292.1 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1239 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1239 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2082593 (1.9 MiB)  TX bytes:2082593 (1.9 MiB)

Worked. However, I know that su then ifconfig used to work. I know it did. I haven't taken any crazy pills in a couple of weeks (GOTTA get off that stuff!!), but I swear it worked before. And I'm not sure what I did to bork it (I had to have done something...)

sem007 08-18-2010 11:04 AM

Quote:

but I swear it worked before. And I'm not sure what I did to bork it (I had to have done something...)
you can do this way. ( just do this as testing only)


login as non-root user.
open your local profile

Code:

$ vim .bash_profile

PATH=$PATH:$HOME/bin:/sbin <- add /sbin

save file and logout and login user

settings for redhat/centos OS

Hope this help

Best of luck.

sheykh 08-18-2010 11:34 AM

Quote:

Originally Posted by sem007 (Post 4070387)
Code:

$ vim .bash_profile

PATH=$PATH:$HOME/bin:/sbin <- add /sbin

save file and logout and login user


That worked like a champ! Didn't need to su. Granted, I see what it is that I did. Basically the same thing as W$ users "paths". Correct? You mentioned that this isn't really a fix, but more a test. Right?


All times are GMT -5. The time now is 05:50 AM.