Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I think there used to be a command to do that but I forget.

Something like ipconfig in windows.

My server has 10 available IPs and I want to know them all.

share|improve this question
ifconfig or ip a s – Ulrich Dangel Mar 18 '13 at 5:03
@UlrichDangel The Q&A is simple, but that is still the answer. – jordanm Mar 18 '13 at 5:10
ip r l .......... :) – Rahul Patil Mar 18 '13 at 8:02
@jordanm i couldn't really believe it and didn't feel like writing a lot of text around it. – Ulrich Dangel Mar 18 '13 at 11:16
@UlrichDangel I would have just pasted some example output to "pad" the answer. – jordanm Mar 18 '13 at 15:06
up vote 3 down vote accepted

if you are only interested in the IP addresses but not the other gory details about the network interfaces, /sbin/ifconfig -a | grep "inet addr:" |awk '{print $2}'|cut -d: -f2 gives you all the ip addresses configured on all network interface cards and nothing else.

share|improve this answer
This works perfectly. – Jim Thio Mar 18 '13 at 11:54
grep | awk | cut is pretty bad. awk can do the job of all 3 of those tools. – jordanm Mar 18 '13 at 15:06

Below are some command to extract only IP addresses :

ifconfig | awk -F':' 'NR==2{split($2,a," "); print a[1]}'

ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'

ifconfig eth0 | sed -n 's/^ *inet addr:*\([.0-9]*\).*/\1/p'

To check Public IP

curl ifconfig.me
share|improve this answer
This is actually the most complete solution. However, I've tried and tested Mel's solution. – Jim Thio Mar 18 '13 at 8:11

/sbin/ifconfig -a 'll show you your network interface(s) with details including the IP address.

share|improve this answer

if you have a problem, try

man ifconfig
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.