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

Find where a kind of file is stored
In this case searches for where .desktop files are stored. The resulted is a sorted list of the top directories containing such files.

How many files in the current directory ?
A simple "ls" lists files *and* directories. So we need to "find" the files (type 'f') only. As "find" is recursive by default we must restrict it to the current directory by adding a maximum depth of "1". If you should be using the "zsh" then you can use the dot (.) as a globbing qualifier to denote plain files: zsh> ls *(.) | wc -l for more info see the zsh's manual on expansion and substitution - "man zshexpn".

Generate White Noise
This command will generate white noise through your speakers (assuming you have sound enabled). It's good for staying focused, privacy, coping with tinnitus, etc. I use it to test that the sound works.

Remove audio stream from a media file
This syntax also works for ffmpeg as avconv is a fork of ffmpeg.

Printable random characters
Reads psuedorandom bytes from /dev/urandom, filtering out non-printable ones. Other character classes can be used, such as [:alpha:], [:digit:] and [:alnum:]. To get a string of 10 lowercase letters: $ tr -dc '[:lower:]' < /dev/urandom | head -c 10

Who has the most Apache connections.
This will tell you who has the most Apache connections by IP (replace IPHERE with the actual IP you wish to check). Or if you wish, remove | grep -c IPHERE for the full list.

small CPU benchmark with PI, bc and time.
$ # 4 cores with 2500 pi digits $ CPUBENCH 4 2500 $. $ every core will use 100% cpu and you can see how fast they calculate it. $ if you do 50000 digitits and more it can take hours or days

Simulate typing
this also generates errors (change 4 to higher number for more mistakes)

ThePirateBay.org torrent search
usage: tpb searchterm example: tpb the matrix trilogy This searches for torrents from thepiratebay and displays the top results in reverse order, so the 1st result is at the bottom instead of the top -- which is better for command line users

Use xdg-open to avoid hard coding browser commands
I rarely use the system menu to start applications. I use keyboard shortcuts instead. Keyboard shortcuts are convenient time savers. To configure the shortcuts I use gconf-editor or CompizConfig Settings Manager (if I have Compiz turned on). Lately I've been using Chromium as my browser. Since Chromium is under heavy development it occasionally becomes unusable and I have to switch back to Firefox. I was hard-coding the browser command in my keyboard shortcuts. This became problematic with frequent browser hopping. I now use the xdg-open command when defining my keyboard shortcuts. xdg-open opens a file or URL in the user's preferred application. In the metacity keybinging_commands I have xdg-open http://gmail.com where I used to have firefox http://gmail.com. Now when switching browsers I don't have to update each keyboard binding command I just change my default browser in Ubuntu by clicking through the menu: System / Preferences / Preferred Applications / Web Browser. xdg-open is more convenient for this browser hopper.


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: