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

get stdout to variable and stdout at sametime
Sometimes you want to write the script output to stdout but you need to send it to email. If you use: $ var="$( ls / )"; $ echo -e "$var"; works but, you need to wait the script terminate to bufferize then print the output var; With this way, you can use/work/print the output before the variable receive all the output content, then after it you can use the variable for anything else, like send email.

Show directories in the PATH, one per line
This version uses Pipes, but is easier for the common user to grasp... instead of using sed or some other more complicated method, it uses the tr command

Fixes Centos 6.2 yum's metalink certificate errors
Fix's centos 6.2 yum's error: could not get metalink https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64 error was 14: PYCURL ERROR 77 - "Problem with the SSL CA cert (path? access rights?)" Error: Cannot retrieve metalink for repository: epel-source. Please verify its path and try again

FizzBuzz one-liner in Python
A common programming question for interviewers to ask potential job candidates is to code "FizzBuzz". That is, if a number is divisible by 3, then it should display "Fizz". If a number is divisible by 5, it should display "Buzz". If it is divisible by both, then it should display "FizzBuzz". Otherwise, display the current number between 1 and 100.

Watch YouTube and other Flash videos via mplayer (or whatever)
Many sites with Flash video players will download video files to /tmp on Linux, with temporary filenames like "FlashbGTHm4". These will often play in mplayer, totem, or other movie playing software. You must first navigate to a video page, let it start loading, and then pause playback.

Poke a Webserver to see what it's powered by.
the good: Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.4 with Suhosin-Patch the bad: Server: Microsoft-IIS/6.0 and the ugly: Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8i PHP/5.2.6

Octal ls
Do ls with permissions written in octal form.

Day of the week of your birthday over the years.
Do you ever want to know which day of week was your birhday! Now you can check that with this command, just set your birh date at the beginning (My bday in the example) and the dates will be revealed. ;)

Sort files by size

Download Apple movie trailers
Copy the link to an HD movie trailer in to this command. It's more eleganant if it's put in a to a script, taking the URL as input.


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: