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:
The host command comes with the bind-utils package, which is has a better chance to be installed than resolveip from mysql. The last word of the query result is displayed, which is the last result host got.
This works with CNAMEs.
You get "3(NXDOMAIN)" in case of failure.
parrallel execution of a command on remote host by ssh or rsh or ...
very useful for cluster management (software update)
Get just the IP address for a given hostname. For best results, make this a function in your shell rc file so that it can be used for things like traceroute:
Titus:~$ traceroute `getip foo.com`
traceroute to 64.94.125.138 (64.94.125.138), 64 hops max, 52 byte packets
Ssh to host1, host2, and host3, executing on each host and saving the output in {host}.log.
I don't have the 'parallel' command installed, otherwise it sounds interesting and less cryptic.
With no '-q 0' switch, nc simply waits, and whatever awaits the data hangs.
Much simpler method. More portable version: ssh host -l user "`cat cmd.txt`"
I was tired of the endless quoting, unquoting, re-quoting, and escaping characters that left me with working, but barely comprehensible shell one-liners. It can be really frustrating, especially if the local and remote shells differ and have their own escaping and quoting rules. I decided to try a different approach and ended up with this.
traverses e.g. "/data/myhost1.com/myrsyncshare"; logs stderr and stdout. useful with cron.
I must monitorize a couple of ftp servers every morning WITHOUT a port-scanner
Instead of ftp'ing on 100 ftp servers manually to test their status I use this loop.
It might be adaptable to other services, however it may require a 'logout' string instead of 'quit'.
The file ftps.txt contains the full list of ftp servers to monitorize.
To also move the db backup to another location you could pass the output to the dd command instead of a file
mysqldump -u user -h host -ppwd -B dbname | bzip2 -zc9 | dd ssh usr@server "dd of=db_dump"
I'm just a simple programmer. I find dig too verbose. host tells me alias(es) and IP address in a quick to grok format with nothing special to remember for input parameters.
With thanks to http://www.cyberciti.biz/faq/how-to-test-or-check-reverse-dns/
Its very useful when you do not have control over name servers and need to check DNS configuration directly, right after change. You will not need to wait for DNS propagation to verify if all records were configured properly by vendors of name servers.
After this, just type:
beepwhenup
You need to install "beep" before this would make the beep sound.
Save it in your .profile if you want to use it later
WARNING: this command won't exit until it is successful. You won't be able to CONTROL+C out of it.
If the connection works you should see a "hello" on host A. If not: check your cabeling etc :-)
Using DynDNS or a similar service not only allows access to your home machine from outside without needing to know what IP the ISP has assigned to it but it also comes in handy if you want to know your external IP address. The only purpose of the sed command is to remove the leading "host.na.me has address " part from the output. If you don't need to discard it you can simply use
host $HOSTNAME
Note, the [remotePort] should be opened in the firewall first. First, start the destination box listening, then fire off the sending box. Data from the /dev/zero device in memory of the source machine is read out using dd, sent over the network with nc, and read back in from the other side of the network with nc, going to the /dev/null device. Essentially, it is a memory-network-memory copy operation, the output of dd will tell you how fast your network really is performing.
this bzips a folder and transfers it over the network to "host" at 777k bit/s.
cstream can do a lot more, have a look http://www.cons.org/cracauer/cstream.html#usage
for example:
echo w00t, i'm 733+ | cstream -b1 -t2
hehe :)