Get the line containing "inet addr:" and the line before that, get down to only the first line, and then get the first word on that line, which should be the interface. Show Sample Output
Easy way to grab the IP address of a machine for easy script use. If needed a "| grep -v 127.0.0.1" at the end will suppress localhost. Show Sample Output
This is what we use. You can grep -v 127.0.0.1 if you wish.
This command is useful when you want to check your nic's mac address, if you're interested in your wireless interface, use its ID instead "eth". This command was tested under Ubuntu and Slackware GNU/Linux. Show Sample Output
If you don't send an interface, it shows private IP address of all interfaces
The command above has been changed due to very good constructive criticism - thanks x 2! This command can be used after acquiring mac's, ip's and hostname's or any of the above from a freshly scanned LAN. User must be root, and remember to change your settings on your network managing software manually (Fedc10 NetworkManager Applet 0.7.1 is mine) instead of 'auto DHCP'. You can also substitute eth0 for wlan0 etc - be good and ENJOY!
Gets the internal and external IP addresses of all your interfaces, or the ones given as arguments Show Sample Output
grabs your local IP Address. Show Sample Output
This doesn't make any assumptions about your IP address and prints out one IP address per line if you have multiple network interfaces. Show Sample Output
gets the last number of the mac address to use it for other stuff Show Sample Output
This will get the mac address of the eth0 and change lowercase to uppercase. The sed command removed the colons.
short enough to be tweetable Show Sample Output
You can use this to loop any command to periodically see the output.
while true; do [YOUR COMMAND HERE]; sleep [# of seconds]; done;
Alternatively, you can put it in a simple shell script to save typing!
#/!bin/bash
while true; do $1; sleep $2; done;
/path/to/script.sh "ifconfig eth0 | grep 'inet addr:'" 60
Show Sample Output
HP UX doesn't have a -a switch in the ifconfig command. This line emulates the same result shown in Solaris, AIX or Linux Show Sample Output
This assumes your local ip starts with 192.something (e.g. 192.168), it greps ifconfig output for an ip that starts with 192, then strips the extra garbage (besides the ip) Maybe `ifconfig | grep addr | grep Bcast` would also do it Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: