Use Google as Search Engine in Firefox Awesome Bar

The latest version of Firefox (4.0.1) had me coming back to the first browser I loved, after breaking up with it in favor of (in order) Chrome, Chromium and Opera. It’s really sleek, minimalistic and fast (!).

One thing I’ve grown used to is to perform google searches directly from the address bar, and it is something I can no longer bear to live without.

My ISP has its own lame search engine, and everytime I tried to search for something it redirected me to its ugly page filled up with Google Ads (quite a coincidence, right?) and even after following the tuning hints given by Mozilla itself there was no way out of it.

So, I switched to OpenDNS (btw, in the golden times they used to show you their IPs first thing, now with all those blatant marketing stuff you have to resort on wikipedia to get 208.67.222.222 and 208.67.220.220) but now I got redirected to OpenDNS’s own lame search page!

In the end, the only way I found to use Google was to use… Google’s own public DNS servers, located at 8.8.8.8 and 8.8.4.4 (all my data passing through Google is getting scarier year after year, but you know, having several Gmail accounts using BigG as DNS provider isn’t making things worse than they currently are…)

Advertisements

Displaying a progress bar while using dd

[Update – June 2017] – as nvoss noted in the comments, as of coreutils version 8.24 (published 2 years ago), dd supports a nice status=progress option which does exactly what this post is about… At last! 🙂

dd is one tool I really love and one that really scares the hell out of me. It’s so powerful you have to show him respect, otherwise you’ll end up destroying all your precious data!
One thing it’s not very good at however is to show you some info on what’s going on and, most of all, how fast your files are being shredded to pieces never to come back again 🙂

So, say we’re using dd like this:

dd if=/path/to/input_file of=/path/to/output_file bs=4096

To get the usual

N record in
N record out
N bytes copied, M seconds, P transfer rate

we all learned to love, you can just

sudo killall -USR1 $DD_PID

from within another terminal and dd will display its statistics to the terminal you launched it from. Of course, you may add some

watch --interval=10 killall -USR1 $DD_PID

to update statistics at regular intervals.

But this is just boring.. What about some sort of progress bar? 😉

The trick is to break down dd in its input and output parts, and throw a pv in the middle, like this:

dd if=/path/to/input_file bs=4096 | pv -s SIZE_OF_INPUT_FILE | dd of=/path/to/output_file bs=4096

where SIZE_OF_INPUT_FILE is your best estimate of input_file size (M and G may of course be used for megabytes and gigabytes), and voilà, you get a progress bar that looks like wget‘s!

pv comes as a package for a lot of Linux distributions, so it should be no issue to (apt-)get it.

You may also have stat guess the file size for you, like it’s written here, but in case you’re dealing with /dev/sdX and such you’re out of luck, as stat will always tell your file is 0 bytes long.

SSH Tunneling with joy!

When dealing with several servers that don’t all see each other it is often a bit painful to jump from one SSH session to another, even more so if you have to type some password every time.
In case you are allowed to edit .ssh/authorized_keys (I don’t see a valid reason why you shouldn’t, but in the wonderful world of system administrators.. who knows?) your struggle is about to end. Provided, of course, that you use Linux 🙂

Let’s say you want to reach hostB (unreachable from your own host) by tunneling over hostA (which you have direct access to).

  1. Edit your .ssh/config file to include a stanza for each host; it should look like this:
    Host hostA
    User myUserNameForHostA
    HostName hostA.domain.com
    Port 22
    
    Host hostB
    User root
    HostName hostB.as.seen.from.hostA
    ForwardAgent yes
    Port 22
    ProxyCommand ssh hostA nc %h %p
    

    This will also let you type ssh h<TAB> having the shell auto-complete magic fill the remaining “ost” for you (the remaining A or B is up to you). Right now you may already tunnel over A to reach B, but still you would have to type in passwords for both host A and hostB every time you ssh hostB.

  2. Generate your id_rsa.pub in case you don’t have one, and add it to the authorized_keys list of both hostA and hostB:
    ssh-keygen -t rsa
    cat ~/.ssh/id_rsa.pub | ssh hostA 'cat >> .ssh/authorized_keys'
    cat ~/.ssh/id_rsa.pub | ssh hostB 'cat >> .ssh/authorized_keys'
    

And you’re done! Now you can ssh hostB without having to type any password!

In case hostA and/or hostB don’t have a .ssh folder, you should of course create it by executing

ssh hostA mkdir -p .ssh
ssh hostB mkdir -p .ssh

Nice thing is, you may also add a hostC that is accessible from hostB only by adding an entry to .ssh/config as you’ve done for hostB, carefully switching hostA with hostB and hostB with hostC!