Fog Creek Software
Discussion Board




How to check my IP in Linux?

I have a text based Linux server - how do I check my IP?

I tried using "ifconfig" but received a 'command not found' error.

Prarie Dog
Tuesday, April 13, 2004

/sbin/ifconfig

Often, people add /sbin:/usr/sbin to their path to pick these things up.

hoser
Tuesday, April 13, 2004

If you've logged in as root, ifconfig should work. 

Alternatively, if you use su, don't forget the dash.  i.e su -

Koz
Tuesday, April 13, 2004

Ask SCO to audit it for you?

couldn't resist, sorry
Tuesday, April 13, 2004

ifconfig generally works even if you aren't root. It's just not in the default PATH, so you have to type /sbin/ifconfig

Egor
Tuesday, April 13, 2004

You can try typing 'ip address show' (or '/sbin/ip address show')  as well. This is a newer syntax not available on all machines. ifconfig should work everywhere.

Jonas B.
Tuesday, April 13, 2004

There are a great family of very simple but very useful scripts that, in Debian at least, come packaged with the 'ipmasq' package (and should be separated from it into a new package, IMHO, due to their usefulness). The one relevant to what you want is called 'ipofif', and is simply

#!/bin/sh
#
# ipofif        Determines the IP address of the interface given on the
#              commandline
#
# v1.0  19 July 1998
# v1.1  12 June 1999
# v1.2  10 Feb 2001
#####

export LC_ALL="C"
export LANG="C"
export LANGUAGE="C"

/sbin/ifconfig $1 | grep 'inet addr:' | sed 's/.*inet addr:\([0-9.]*\).*/\1/g'

John Lenton
Tuesday, April 13, 2004

hostname -i

Will
Wednesday, April 14, 2004

You know you've been reading GrokLaw too long when you parse the "IP" in the title as "Intellectual Property"

Edgewood
Thursday, April 15, 2004

*  Recent Topics

*  Fog Creek Home