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.
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:
The example runs 'puppet' in a loop for 10 times, but exits the loop before if it returns 0 (that means "no changes on last run" for puppet).
passthru, shell_exec, system, phpinfo, base64_decode, chmod, mkdir, fopen, fclose, readfile
Since some of the strings may occur in normal text or legitimately you will need to adjust the command or the entire regex to suit your needs.
This will show you the permissions on the directory you are currently in
I found this command on a different site and thought you guy might enjoy it. Just change "YOURSEARCH" to what ever you want to search. Example, "Linux Commands"
Fast and easy way to find all established tcp connections without using the netstat command.
This is longer than others on here. The reason for this is I have combined two different matrix commands so it would work on all computers. I logged onto my server through a computer and it worked fine. I logged into my server through a mac and it looked $4!t so I have made one that works through both.
Example of zsh globing, glob qualifier, and substitution:
-Q state that the parameter will contain a glob qualifier.
(**/)(*) is recursive
(.) is our glob qualifier, with states the match is a file "."
The first parameter $1, is then substituted with $2 but with lowercasing '(L)' ... a (U) would of course be from lower to upper.
An example of zsh glob qualifiers.
Example of using zsh glob qualifier ...
"." = files
"f:" = files with access rights matching:
o+w = other plus write
Shows which applications are making connections, and the addresses they're connecting to. Refreshes every 2 seconds (watch's default). Test on OSX, should work anywhere watch and lsof work.
is preserving creation time, modification time, permission, the directory structure, etc.
Go to "https://twitter.com/search/realtime?q=%23TeamFollowBack&src=hash" and then copy al the text on the page. If you scroll down the page will be bigger. Then put al the text in a text file called twit.txt
If you follow the user there is a high probability the users give you follow back.
To follow all the users you can use an iMacros script.
Uses find, plutil and xpath.
Note: Some applications don't have proper information. system_profiler might be better to use.
It's a bit slow query.
Due to command length limit, I removed -name "*.app" and CFBundleName.
Replace "Master" with desired control name (e.g. Front, Earphone, PCM, etc.).
This command produces no output, but its exit status is 0 ("true") if $file is text, non-0 ("false") if $file is binary (or is not accessible).
-q suppresses all the output of grep
-I is the trick: if a binary file is found, it is considered a non-match
-m 1: limit "output" to first match (speed up for big files)
.: the match string, "." stands for any character
Usage: e.g. run editor only on text files
grep -qIm 1 . $file && vi $file
xargs is a more elegant approach to executing a command on find results then -exec as -exec is meant as a filtering flag.