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

Execute a command on logout
Execute a command on shell logout,and run it until is finished,then shell is closed.

Pick a random image from a directory (and subdirectories) every thirty minutes and set it as xfce4 wallpaper
Change your wallpaper every thirty minutes (or however long you like, I suppose) to a randomly selected image in a directory and subdirectories. Bear in mind this is not safe to use if anyone else has write access to your image directory.

Get a metascore from metacritic.com
This will fetch a metascore from metacritic.com. It requires a url from metacritic without the http://www.metacritic.com/ Example: $ metascore games/platforms/wii/supermariogalaxy - $ metascore tv/shows/marriageref - $ metascore video/titles/newmoon Would be cool to use this in some sort of a graph.

Quickly analyse an Apache error log
This searches the Apache error_log for each of the 5 most significant Apache error levels, if any are found the date is then cut from the output in order to sort then print the most common occurrence of each error.

check open ports without netstat or lsof

set prompt and terminal title to display hostname, user ID and pwd
used in an if-then-else in case the default shell is ksh, not bash. The $(basename ${0#-}) is handy to echo which shell and strip the dash some flavors put in front of "bash" if [ $(basename ${0#-}) == "bash" ] ; then export PS1='\[\e]0;\h \u \w\a\]\n\[\e[0;34m\]\u@\h \[\e[33m\]\w\[\e[0;32m\]\n\$ ' else HOST=`hostname` ESC=`echo "\033"` BEL=`echo "\007"` RAW=`echo "\r"` export PS1='-${RAW}${ESC}]0;${HOST} ${USER}${BEL}-${ESC}[0;34m${USER}${ESC}[0m@${ESC}[0;34m${HOST%%.*}${ESC}[0;33m${ESC}[0m $ ' fi

cat ~/.ssh/id_rsa.pub | ssh user@site.com "cat - >> ~/.ssh/authorized_keys"
You'll want to use this for passwordless logins. Same as ssh-copy-id, if you don't have it on your system.

Copy your SSH public key on a remote machine for passwordless login.
Should run on any system with ssh installed.

List PCI device with class and vendor/device IDs
This is a quick replacement for lspci if you need to know what's in a given system but pciutils is not installed. You then need something that can look up the IDs from pci.ids if you want the verbose output.

let the cow suggest some commit messages for you


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: