View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > General
User Name
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!


  Search this Thread
Old 02-25-2013, 02:27 PM   #1
LQ Newbie
Registered: Aug 2011
Posts: 8

Rep: Reputation: Disabled
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...
Old 02-25-2013, 02:43 PM   #2
Senior Member
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 4,937

Rep: Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152
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.

Last edited by 273; 02-25-2013 at 02:44 PM.
Old 02-25-2013, 02:44 PM   #3
Senior Member
Registered: Mar 2011
Location: Milford, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 2,879
Blog Entries: 9

Rep: Reputation: 951Reputation: 951Reputation: 951Reputation: 951Reputation: 951Reputation: 951Reputation: 951Reputation: 951
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.
Old 02-25-2013, 03:04 PM   #4
LQ Newbie
Registered: Aug 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank You

Yep,,,, hostname -I real works thaning you.....
Old 03-05-2013, 08:20 AM   #5
LQ Newbie
Registered: Oct 2012
Posts: 26

Rep: Reputation: Disabled
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
Old 03-08-2013, 07:20 AM   #6
Senior Member
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
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}'


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i configure dns of two ipadress in single system jaikumar75 Linux - Server 1 11-02-2011 01:29 PM
Ubuntu display problem on dual display system joboy Linux - General 2 05-01-2011 11:00 AM
i want use onboard 2nics with same class ipadress in rhel4. dsol Linux - Networking 2 12-25-2006 02:48 PM
X display on another system unzari Fedora 2 04-28-2005 02:14 AM

All times are GMT -5. The time now is 02:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration