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

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"

Get information on your graphics card on linux (such as graphics memory size)
probably only works if you have one graphics card. used this: http://www.cyberciti.biz/faq/howto-find-linux-vga-video-card-ram/ as reference can be expanded, for example: $ lspci -v -s `lspci | awk '/VGA/{print $1}'` | sed -n '/Memory.*, prefetchable/s/.*\[size=\([^]]\+\)\]/\1/p' will just get the amount of prefetchable memory compare to: $ lshw -C display which does not give the size (it does give byte ranges and you could calculate the size from that, but that's a pain) Also uses a command which is not standard on linux; wheras lspci is a core utility provided by most systems

stringContains: Determining if a String Contains a Substring

generate random number

prints line numbers
the sed way to print line numbers

fdiff is a 'filtered diff'. Given a text filter and two inputs, will run the filter across the input files and diff the output.
Fdiff will run the command given by the first argument against the input files given as the second and third arguments, and diff the results. It will use 'diff' as the default diff program, but this can be changed by setting $DIFFCMD, e.g. $ export DIFFCMD=vimdiff; $ fdiff zcat 0716_0020005.raw.gz 0716_0030005.raw.gz ... This function will work under bash, but requires the use of command substitution, which is not available under a strict ANSI shell.

Show URL/text in clipboard as QR code
Copy a URL (or Thai text, or whatever) and hit the keyboard shortcut for this fu to display it as a QR code. It's an "air gapped" way to send stuff to your phone [unlike google chart API etc.] as long as you watch out for cameras ;). dependencies [sudo apt-get install]: qrencode xclip xloadimage

random xkcd comic
i sorta stole this from http://www.shell-fu.org/lister.php?id=878#MTC_form but it didn't work, so here it is, fixed. --- updated to work with jpegs, and to use a fancy positive look behind assertion.

Counts number of lines (in source code excluding comments)
I took java to make the find command simpler and to state that it works for any language supported by cpp. cpp is the C/C++ preprocessor (interprets macros, removes comments, inserts includes, resolves trigraphs). The -fpreprocessor option tells cpp to assume the input has already been preprocessed so it will only replace comment lines with blank lines. The -L 1 option tells xargs to launch one process for each line, indeed cpp can only process one file at the time...

Extract neatly a rar compressed file
It's also possible to delay the extraction (echo "unrar e ... fi" |at now+20 minutes) wich is really convenient!


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: