LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What shell command supplies IP address ? (https://www.linuxquestions.org/questions/linux-newbie-8/what-shell-command-supplies-ip-address-464313/)

shakersort 07-15-2006 11:12 AM

What shell command supplies IP address ?
 
I don't know what shell command line supplies IP address ? Please tell me !

Theorist 07-15-2006 11:20 AM

Hi shakersort,
If you want to know the IP address of the machine that you are using, run
Quote:

$ /sbin/ifconfig
With Regards,
Theorist

hal8000b 07-15-2006 11:49 AM

Quote:

Originally Posted by shakersort
I don't know what shell command line supplies IP address ? Please tell me !

You can also use "ip addr" . The command is ip soif its not in your path try /bin/ip addr
or /sbin/ip addr

anc@orac:~> /bin/ip addr
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0e:a6:8c:f3:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.254.197/24 brd 192.168.254.255 scope global eth0
inet6 fe80::20e:a6ff:fe8c:f316/64 scope link
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0

Crito 07-15-2006 04:00 PM

You can spell it out instead of abbreviating too. So to find your ip address at the command line you type ip address at the command line. Damn that's just too easy! Why can't Windows be so simple? LOL :o :p

[climber@blackhole ~]$ ip address
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: dev11254: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
link/ether 00:c1:ff:3a:b3:8e brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:a3:4e:ef:7b:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
inet6 fe80::214:2aff:fe1f:9c14/64 scope link
valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0

osor 07-15-2006 07:20 PM

Quote:

Originally Posted by Crito
You can spell it out instead of abbreviating too. So to find your ip address at the command line you type ip address at the command line. Damn that's just too easy! Why can't Windows be so simple? LOL :o :p

Actually, the latest versions of iproute2 do not accept `ip addr' anymore. You must use `ip address' (or patch the source yourself). I'm not sure whose idea it was to change this (or even if s/he realized the consequences), and I don't have time to find out.

gilead 07-15-2006 07:27 PM

If you just want the IP address of eth0 and nothing else (for example to use in a variable or script) you can use this:
Code:

ifconfig eth0 | grep "inet addr:" | awk -F: {'print $2'} | cut -d\  -f 1
You'll probably have to use the full path to ifconfig if you're not root.

titanium_geek 07-16-2006 01:21 AM

this is also the completely wrong forum for this question- I've reported it to the moderators so it can be moved to a better place. (to help other people with the problem find it easily)

titanium_geek

EDIT - apologies for harsh sounding tone. added a :) to make it feel happier.

gilead 07-16-2006 02:24 AM

Quote:

Originally Posted by titanium_geek
this is also the completely wrong forum for this question - I've reported it to the moderators so it can be moved to a better place

Thanks for that - I have to admit I didn't pay attention to the forum it was in, just saw it in a listing of new posts...

jeremy 07-16-2006 01:59 PM

Moved: This thread is more suitable in Linux - Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.

--jeremy


All times are GMT -5. The time now is 06:23 AM.