-   General (
-   -   How to display only ipadress of system? (

wwinay 02-25-2013 01:27 PM

How to display only ipadress of system?
Hello Linux Lovers, i have one trouble that how to display only ip address of systeme like insted of displaying all ifconfig result...please help me out...

Thank You...

273 02-25-2013 01:43 PM

I was curious so I googled and found this:

hostname -i
However, for me that just gives, so I tried:

hostname -I
Which seems to do the job.
Edit: I should add that this can be run as a non-root user also, which is nice.

rtmistler 02-25-2013 01:44 PM

Depends if you need it via the shell or in a program.

One way would be: (for interface "eth0"


ifconfig eth0 | grep "inet addr"
That still shows the broadcast address and subsystem mask.

You can post process that result to get only the IP address portion of that.

wwinay 02-25-2013 02:04 PM

Thank You
Yep,,,, hostname -I real works thaning you.....

venkatesh51 03-05-2013 07:20 AM

host hostname
inorder to display ip address only
we need to follow the steps
$host (hostname)(hostname will come from the above command)
ex $host ravi

w1k0 03-08-2013 06:20 AM

Slackware 14.0:

hostname -I

hostname: invalid option -- 'I'
/sbin/ifconfig eth0 | grep "inet addr"

(Empty output.)


1. Your distribution uses some other hostname program version.

2. Modern ifconfig changed the format of the displayed data.


/sbin/ifconfig eth0 | grep "inet" | awk '{print $2}'

All times are GMT -5. The time now is 02:31 AM.