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:
Ok so it's rellay useless line and I sorry for that, furthermore that's nothing optimized at all...
At the beginning I didn't managed by using netstat -p to print out which process was handling that open port 4444, I realize at the end I was not root and security restrictions applied ;p
It's nevertheless a (good ?) way to see how ps(tree) works, as it acts exactly the same way by reading in /proc
So for a specific port, this line returns the calling command line of every thread that handle the associated socket
This works just like write or wall ... cept one thing the sender is anonymous ... if you really want to drive everyone insane replace echo \"The Matrix has you...\" with cat /dev/urandom
nice one to do on April fool's day
use today's time stamp to make a unique directory for today or an hour ago ...
Useful for switching over someone else's coding style who uses camelCase notation to your style using all lowercase with underscores.
A powerfull way to rename file using sed groups.
& stand for the matched expression.
\1 referes to the first group between parenthesis. \2 to the second.
url can be a working copy or url to a svn repository, revision is any valid revision number for that branch.
This command puts all the flags of the USE variable actually used by the packages you emerged to the file "use", and those which are unused but available to the file "notuse"
If you're like me and want to keep all your music rated, and you use xmms2, you might like this command.
I takes 10 random songs from your xmms2 library that don't have any rating, and adds them to your current playlist. You can then rate them in another xmms2 client that supports rating (I like kuechenstation).
I'm pretty sure there's a better way to do the grep ... | sed ... part, probably with awk, but I don't know awk, so I'd welcome any suggestions.
After every line in targetfile (empty lines included) insert in a line from addfile. "Save" results to savefile. Addfile should be longer than targetfile since this doesn't loop back to the top of addfile.
/^/R addfile -- says for every line that matches "has a start of line" output a line from the file addfile.
> savefile (optional) -- redirect output to savefile file.
Declare this function in your Shell, then use it like this:
> jumpTo foo
The script will search for the 'foo' pattern in your current xmms2 playlist (artist or songname), and play the first occurence of it !
Linux : these script enable you to edit multiple files and remove exact phrase from multiple files
Remove blank lines from files, even if some of the lines have whitespace (spaces, tabs, etc.). Also creates a .bak copy of the original file. Works on Mac also.
Thanks to those all those who left comments.
But who knows to delete the rest of the lines?
I want only "string".
Are there any creative pieces of music that can be created using beep and the shell? I'd love to hear it!
Look for a string in one of your codes, excluding the files with svn and ~ (temp/back up files). This can be useful when you're looking for a particular string in one of your source codes for example, inside a directory which is under version control (e.g. svn), removing all the annoying files with ~ (tilde) from the search. you can even change the command after -exec to delete (rm) or view (cat) files found by 'find' for example
Searches the /var/log/secure log file for Failed and/or invalid user log in attempts.
Some commands (such as netcat) have a port option but how can you know which ports are unused?
Extensible to other ugly extensions like *.JPG, *.Jpg etc..
Leave out the last pipe to sh to perform a dry run.
Allows for quick mass renaming, assuming the user has some familiarity with regular expressions. Basically, it replaces the original_file_name in the output of ls with
"mv -v original_file_name new_file_name"
and passes the output to sh.