All commands (14,187)

What's this?

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.

Share Your Commands


Check These Out

Grab IP address on machine with multiple interfaces
Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way. This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1). This uses a well known public ip address 8.8.8.8, but it doesn't actually connect to it, it just shows you the route it would take.

repeat a command every one second
Short method of "while x=0; do foo ; sleep 1 ; done"

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

grep -v with multiple patterns.
If you wanted to do all in one command, you could go w/ sed instead

Copy a directory recursively without data/files

Show a script or config file without comments or blank lines

Rename files in batch

list block devices
Shows all block devices in a tree with descruptions of what they are.

search the manual page names and descriptions

ssh autocomplete based on ~/.ssh/config
I sue this in my .bashrc file This will also do auto-completion for scp and sftp


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: