commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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
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:
apt-get must be run as root, and it is useless to run it as your own user. So just run it as root. Saves you the "sudo !!" every time you're adding a package.
If your web server is down, this command will periodically attempt to connect to it. If the output is blank, your server is not yet up. If you see HTML, your server is up. Obviously, you need to replace the Google URL with your web server URL...
* 'watch' -- a command for re-executing a command and displaying
the output
* '-n 15' -- tells watch to redo the command every 15 seconds
* 'curl' -- a handy utility for getting the source of a web page
* '-s' -- tells curl to be silent about failing
* '--connect-timeout 10' -- Try to connect for 10 seconds
get subversion diff output without distracting whitespace changes. good for when you are cleaning up code to make sure you didn't change anything important. also useful when working with old code, or someone else's code.
copying files from one server to another using rysnc. Root access need to be allowed on the destination.
Changing files ownership in a directory recursivley from a user to another
A useful bash function:
gztardir()
{
if [ $# -ne 1 ] ; then
echo "incorrect arguments: should be gztardir "
else
tar zcvf "${1%/}-$(date +%Y%m%d-%H%M).tar.gz" "$1"
fi
}
This removes the type prefix used in Hungarian notation (v. bad) for PHP variables. Eg. variables of the form $intDays, $fltPrice, $arrItems, $objLogger convert to $days, $price, $Items, $logger.
If you are in /begin/path/with/XX/pattern
cd XX YY
will change your current directory to
/begin/path/with/YY/pattern
in ZSH
Not that useful really, more novel. Can open up an awful lot of terminal windows.
Uses the PHP binary to check the syntax of all .php files in or below the current working directory. Really handy for doing that last minute check before you commit code to the repository.
Surround the first letter of what you are grepping with square brackets and you won't have to spawn a second instance of grep -v. You could also use an alias like this (albeit with sed):
alias psgrep='ps aux | grep $(echo $1 | sed "s/^\(.\)/[\1]/g")'
Needs xxdiff installed, which looks a bit clunky but is an extremely powerful graphical diff.
Creates a log of a session in a file called typescript. Or specify the file with:
script filename
Exit the session with control-d.
Shows the current directory and those below it in a simple tree structure. Recommended use:
alias lt='$command_above'