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

Google Spell Checker
I took matthewbauer's cool one-liner and rewrote it as a shell function that returns all the suggestions or outputs "OK" if it doesn't find anything wrong. It should work on ksh, zsh, and bash. Users that don't have tee can leave that part off like this: $spellcheck(){ typeset y=$@;curl -sd "$y" https://google.com/tbproxy/spell|sed -n '/s="[1-9]"/{s/]*>/ /g;s/\t/ /g;s/ *\(.*\)/Suggestions: \1\n/g;p}';}

Delete leading whitespace from the start of each line

Safely remove old unused kernels in Ubuntu/Debian
Removes piling kernels from /boot, save the current one. This command DOES NOT remove the 'linux-image-generic' package, so you'll continue getting kernel updates

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

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.

Rolling upgrades via aptitude
This has been my "sysupgrade" alias since ca. 2006, first used on Debian Sid, then Sabayon, and it still does its duty on Mint nowadays without breaking stuff.

Check a server is up. If it isn't mail me.
Joker wants an email if the Brand X server is down. Set a cron job for every 5 mins with this line and he gets an email when/if a ping takes longer than 3 seconds.

One-liner to generate Self-Signed SSL Certificate+Key without any annoying prompts or CSRs
Handy if you want to quickly generate a self-signed certificate. Also can be used in your automated scripts for generating quick-use certificates.

Rename files in batch

Lists all listening ports together with the PID of the associated process
This command is more portable than it's cousin netstat. It works well on all the BSDs, GNU/Linux, AIX and Mac OS X. You won't find lsof by default on Solaris or HPUX by default, but packages exist around the web for installation, if needed, and the command works as shown. This is the most portable command I can find that lists listening ports and their associated pid.


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: