LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 02-25-2013, 01:27 PM   #1
wwinay
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 172.24.1.1 insted of displaying all ifconfig result...please help me out...

Thank You...
 
Old 02-25-2013, 01:43 PM   #2
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,344

Rep: Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773
I was curious so I googled and found this:
Code:
hostname -i
However, for me that just gives 127.0.0.1, so I tried:
Code:
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 01:44 PM.
 
Old 02-25-2013, 01:44 PM   #3
rtmistler
Senior Member
 
Registered: Mar 2011
Location: Milford, MA. USA
Distribution: MontaVista, Ubuntu, MINT
Posts: 1,080
Blog Entries: 7

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Depends if you need it via the shell or in a program.

One way would be: (for interface "eth0"

Quote:
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, 02:04 PM   #4
wwinay
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, 07:20 AM   #5
venkatesh51
LQ Newbie
 
Registered: Oct 2012
Posts: 26

Rep: Reputation: Disabled
host hostname

inorder to display ip address only
we need to follow the steps
$hostname
$host (hostname)(hostname will come from the above command)
ex $host ravi
 
Old 03-08-2013, 06:20 AM   #6
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,240

Rep: Reputation: 196Reputation: 196
Slackware 14.0:

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

(Empty output.)

Explanations:

1. Your distribution uses some other hostname program version.

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

Solution:

/sbin/ifconfig eth0 | grep "inet" | awk '{print $2}'
Code:
192.168.1.2
deaf:abbe:bade:dead:beef:feed
 
  


Reply


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 12:29 PM
Ubuntu display problem on dual display system joboy Linux - General 2 05-01-2011 10:00 AM
i want use onboard 2nics with same class ipadress in rhel4. dsol Linux - Networking 2 12-25-2006 01:48 PM
X display on another system unzari Fedora 2 04-28-2005 01:14 AM


All times are GMT -5. The time now is 12:47 AM.

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