Hi everyone, nice forum!
I need to know if there's a command that will show the IP Address of the machine you are logged into. Eg when you type hostname it returns the name of the machine, I need one that returns the IP address only. Can anyone help or suggest commands that are almost what I want?
Thanks.
`ifconfig` will give you any details you want (`ifconfig -a`)... or you might be able to grab it from your /etc/hosts file...
grep `hostname` /etc/hosts |awk '{print $1}'
to run ifconfig, you need to be a superuser
if not, just say
hostname -i
thanks
asif
Not on all systems. I was just able to `ifconfig -a` on my FreeBSD system as a common user (not part of the wheel group).
I guess you guys are talking Linux because I can't find that command on my HPUX system.
My commands are:
netstat -rn # shows info from the routing table.
grep `hostname` /etc/hosts

ifconfig -a on Solaris would give you the following type of info - to get the same on HP-UX you would have to do ifconfig lan1 (or specific interface - gather that info from lanscan)
$ ifconfig -a
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 1
inet 10.14.6.6 netmask fffffc00 broadcast 10.14.6.255
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 2
inet 127.0.0.1 netmask ff000000
On HP-UX:
$ lanscan
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
Path Address In# State NamePPA ID Type Support Mjr#
8/4/2/0 0x0060B0F93BA9 1 UP lan1 snap1 1 ETHER Yes 119
$ ifconfig lan1
lan1: flags=843<UP,BROADCAST,RUNNING,MULTICAST>
inet 10.14.8.2 netmask fffffc00 broadcast 10.14.8.255
yes sir,
i was talking about LINUX only.
I think ifconfig -a can be used by any user on all systems, problem is its in /usr/sbin and thats not always in your path.
/usr/sbin/ifconfig -a
but if your root it gives you mor einformation, MAC adress ect etc