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:
This is a quick and easy way of encrypting files in a datastream, without ever really creating an output file from gpg. Useful with cron also, when file(s) have to be sent based on a set schedule.
Some malicious program appends a iframe or script tag to you web pages on some server, use this command to clean them in batch.
The sort utility is well used, but sometimes you want a little chaos. This will randomize the lines of a text file.
BTW, on OS X there is no
| sort -R
option! There is also no
| shuf
These are only in the newer GNU core...
This is also faster than the alternate of:
| awk 'BEGIN { srand() } { print rand() "\t" $0 }' | sort -n | cut -f2-
If the connection works you should see a "hello" on host A. If not: check your cabeling etc :-)
cat -n file : number all line
cat -b file : number only non empty line
see man cat
This just reads in a local file and sends it via email. Works with text or binary. *Requires* local mail server.
This helped me find a botnet that had made into my system. Of course, this is not a foolproof or guarantied way to find all of them or even most of them. But it helped me find it.
Using OpenSSL we can encrypt any input we wish and then use Netcat to create a socket which can be connected to from an externally source (even using a Web Browser)
This will diff your local version of the file with the latest version in svn. I put this in a shell function like so:
svd() { vimdiff <(svn cat "$1") "$1"; }
middlehost allows ssh access from where you are but not securehost.
Use nice ssh piping to simulate scp through A => B => C
setting up the shell function if left as an exercise for the reader. ;-)
Agent forwarding should avoid password typing.
Uses the data in the /proc system, provided by the acpid, to find out the CPU temperature. Can be run on systems without lm-sensors installed as well.
du only accepts lines ending with a NUL, which can be a pain to create. This solves that issue.
If you want certain files out of a directory hierarchy, this will copy just the listed files, but will create the directory hierarchy in the new location ($DIR/)
Plays the sound of the file, should sound like *some* kind of music, most files sound like static but some are really cool.
variations:
sudo cat /dev/sda > /dev/dsp
sudo cat /dev/sda5 | aplay
Check out http://bbs.archlinux.org/viewtopic.php?id=70937 for more variations!
semi-dupe--like http://www.commandlinefu.com/commands/view/985/generate-white-noise but with different syntax and program.