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:
Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast.
Be aware that anything saved in this partition will be gone after your computer is turned off.
syntax follows regular command line expression.
example: let's say you have a directory (with subdirs) that has say 4000 .php files.
All of these files were made via script, but uh-oh, there was a typo!
if the typo is "let's go jome!" but you meant it to say "let's go home!"
find . -name "*.php" | xargs perl -pi -e "s/let\'s\ go\ jome\!/let\'s\ go\ home\!/g"
all better :)
multiline: find . -name "*.php" | xargs perl -p0777i -e 's/knownline1\nknownline2/replaced/m'
indescriminate line replace: find ./ -name '*.php' | xargs perl -pi -e 's/\".*$\"/\new\ line\ content/g'
If you spend all day editing in vi then switching your fingers to Emacs mode just for the command line can be difficult. Use set -o vi in your bash shell and enjoy the power of a real editor.
Have your screen session running in multiple places. (warning, things start to look weird if the terminal windows have different dimensions)
This will ring the system bell once if your script exits successfully and twice if it fails. So you can go look at something else and it will alert you when done. Don't forget to use 'xset b [vol [pitch [duration]]]' to get the bell to sound the way you want.
Kills all processes owned by user MYWIFE (replace MYWIFE with username or ID of your choice)
(Thanks, porges, for the better command)
Reads psuedorandom bytes from /dev/urandom, filtering out non-printable ones. Other character classes can be used, such as [:alpha:], [:digit:] and [:alnum:]. To get a string of 10 lowercase letters:
tr -dc '[:lower:]' < /dev/urandom | head -c 10
Type ^u at password prompt to clear a mistyped password.
Einstein's razor: As simple as possible, but not simpler.
On the destination machine netcat listens on any port (1234 in the example) and sends anything it receives into a file or pipe. On the source machine a separate netcat takes input from a file or pipe and sends it over the network to the listener.
This is great between machines on a LAN where you don't care about authentication, encryption, or compression and I would recommend it for being simpler than anything else in this situation. Over the internet you should use something with better security.
Greps IRC logs for phrases and lists users who said them.
Generated XML files often are poorly formatted. Use this command to properly indent and normalize the file in-place.
...changes modify time and access time. also:
touch -r [file1] [file2] # make file2 timestamp match file1
tar's directory and sends to netcat listening on port 10000
On the client end:
netcat [server ip] 10000 | tar xfvz -
This will send it over the network and extract it on the clients machine.