Commands by Ikem (1)

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

Find 10 largest files in git history

Shorten any Url using bit.ly API, using your API Key which enables you to Track Clicks
Shorten any Url using bit.ly API, using your API Key which enables you to Track Clicks I have it as a Function in my .bash_aliases [code] shorten () { longUrl=$1; curl "http://api.bit.ly/shorten?version=2.0.1&longUrl=LONG_URL_YOU_WANT_SHORTENED&login=rungss&apiKey=" } [/code] Here is an Output showing the Function Detail.. [konsole] bijay@bijay:$ type shorten shorten is a function shorten () { longUrl=$1; curl "http://api.bit.ly/shorten?version=2.0.1&longUrl=$longUrl&login=rungss&apiKey=R_48d7e0b40835b09e3861bd455f7abec7" } [/konsole]

Tail a log file with long lines truncated
This truncates any lines longer than 80 characters. Also useful for looking at different parts of the line, e.g. cut -b 50-100 shows columns 50 through 100.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

grep apache access.log and list IP's by hits and date - sorted

Show a config file without comments

Shows what processes need to be restarted after system upgrade
This command can be installed in debian by the package debian-goodies. It also outputs the /etc/init.d/ commands that you need to do.

Copy sparse files
This causes cp to detect and omit large blocks of nulls. Sparse files are useful for implying a lot of disk space without actually having to write it all out. http://en.wikipedia.org/wiki/Sparse_file You can use it in a pipe too: $ dd if=/dev/zero bs=1M count=5 |cp --sparse=always /dev/stdin SPARSE_FILE

make directory tree

start a VNC server for another user


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: