Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using ifconfig from sorted by
Terminal - Commands using ifconfig - 94 results
for i in `lanscan -i | awk '{print $1}'` ; do ifconfig $i ; done 2> /dev/null
netstat -nr|egrep -v "Routing|Interface|lo0"|awk '{print $5}'|sort -u| while read l; do ifconfig $l ; echo " Station Addr: `lanscan -ia|grep "$l "|cut -d ' ' -f 1`" ; done
ifconfig | egrep -A2 "eth|wlan" | tr -d "\n"| sed 's/\-\-/\n/g'|awk '{print "mac: "$5 " " $7}' | sed 's/addr:/addr: /g'
ifconfig | head -n 2 | tr -d '\n' | sed -n 's/.*\(00:[^ ]*\).*\(adr:[^ ]*\).*/mac:\1 - \2/p'
ifconfig eth0 | grep inet | awk '{ print $2 }'
2014-07-23 20:43:15
User: smorg
Functions: awk grep ifconfig
Tags: centos
0

I just use this to see my ip on the server I'm working on

ifconfig |grep HWaddr |cut -d ' ' -f 1,11 |grep eth0 |cut -d ' ' -f 2|xargs | awk -F':' '{ print $1$2$3$4$5$6 }'
2014-04-25 18:43:47
User: simplewall
Functions: awk cut grep ifconfig xargs
0

Many tasks need mac id check. above command exactly do the same

ifconfig | egrep [0-9A-Za-z]{2}\(:[0-9A-Za-z]{2}\){5} | awk '{print $1 ":\t" $5}'
2013-07-30 17:02:07
User: jaimeanrm
Functions: awk egrep ifconfig
1

Is the better option on a Open SuSE Box

ifconfig -a | awk '/Bcast/{print $2}' | cut -c 5-19
ifconfig -a | awk '/Bcast/{print $2}' | cut -c 5-19
print ${$(ifconfig wlan0)[6]}
2013-03-23 20:29:29
User: khayyam
Functions: ifconfig
Tags: zsh
0

A method for aquiring the ip address using zsh. If you prefer the use of iproute2 (which, frankly, you should) then the following should provide the same (ip outputs CIDR addresses):

print ${$(ip -o -4 a s eth0)[4]}

we could also pass a qualifier to take only the IP and not the (CIDR) mask

print ${$(ip -o -4 a s eth0)[4]:h}

or, similarly, for the MAC address:

print ${$(ip l l eth0)[15]}

ifconfig eth0|awk '/HWaddr/{gsub(/:/,"",$5);print $5}'
ifconfig wlan0 hw ether 00:11:22:33:44:55
2013-02-26 21:27:47
User: mutiny1939
Functions: ifconfig
1

The 00:11:22:33:44:55 is whatever you want your new MAC address to be. Sometimes sudo should be used in front if you need to.

sudo ifconfig wlan0 | grep inet | awk 'NR==1 {print $2}' | cut -c 6-
2013-02-18 14:10:07
User: mouths
Functions: awk cut grep ifconfig sudo
-1

On wired connections set 'eth0' instead of 'wlan0'

ifconfig | grep inet
2012-12-05 20:54:07
User: Karunamon
Functions: grep ifconfig
Tags: Linux ifconfig
0

Returns the IP, broadcast, and subnet mask of your interfaces absent any other extraneous info.

I know it's a bit lame, but I've created an alias for this when I *quickly* want to know what a system's IP is. Small amounts of time add up :)

ifconfig |grep broadcast | awk '{print $2}'
2012-12-05 03:57:51
User: fotoflo
Functions: awk grep ifconfig
-12

get the ip address on your LAN

ifconfig |grep broadcast | awk '{print $2}'
ifconfig eth0 | grep HW | cut -d " " -f 11
ifconfig | sed -n 's/.*inet addr:\([0-9.]\+\)\s.*/\1/p'
ifconfig | awk -F"[: ]+" '/inet addr/ {print $4}'
ifconfig | grep "inet" | tail -1 | awk '{print $2}'
ifconfig | grep "inet" | grep "broadcast" | awk '{print $2}'
ifconfig | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1
ifconfig eth0 allmulti
2012-05-25 16:43:41
User: SEJeff
Functions: ifconfig
0

Disabling an interface's multicast filter is like disabling IGMP snooping on a switch. It is useful for testing and troubleshooting.

for i in `netstat -rn|egrep -v "Interface|Routing"|awk '{print $5}'`;do ifconfig $i;done
ifconfig | awk '/inet / {sub(/addr:/, "", $2); print $2}'