Automatic “1st result” on Firefox

This is not a post only for linux user, but is for all the “Firefox users“.

Here I simply post the method to allow Firefox to show the first result of the Google search, only tiping some keywords in the adress bar, without clicking on the results list of Google.
This function was implemented in the older versions of Firefox (like the 7th-8th), but in the modern versions it appears the list of Google and you must select the result that you want.

So, to enable this function, go to the address bar and type
about:config
and then promise to Firefox that you’ll be careful with the configuration parameters.   XD

In the Search field, type keyword: it can show only few item.
Then,

  1. set  keyword.enabled   to   true
  2. set   keyword.URL   to   http://www.google.it/search?ie=UTF-8&sourceid=navclient&gfns=1&q=

 

Now, enjoy you new searches!   ;o)

Compare files and folders

When you need to compare files and folders (and folder trees), you can use the bash command diff.

I analyze the complex case of compare folder trees, for example when you have two directory trees maked in the same mode, but not really equal.
So, you must type:

$ diff -rw project1/ project2/ | diffstat

where i use the -r option to recursively compare any subdirectories, and the option -w to ignore all whte spaces.
At the end, i use the diffstat command to make histogram from diff-output, that transform the output in a best view.

If you have too many files and folders to analyze, you can read in the best way using the less command, appended after diffstat with a pipe.

 

Enjoy!!  ;)

Ethernet virtual-interfaces (Debian system)

If you need more than one ethernet interface on your machine, you need a virtual-interface!
An ethernet virtual interface it’s an autonomous interface with an IP address, that simulates a physical ethernet interface.

On a debian-based OS, for more ethernet interfaces on a single physical interface you must add these lines at the end of interfaces, assuming eth1 the default physical interfaces:

auto lo
iface lo inet loopback

auto eth1 eth1:0

iface eth1:0 inet static
address 192.168.1.71
        netmask 255.255.255.0
        gateway 192.168.1.1
iface eth1 inet static
        address 192.168.1.70
        netmask 255.255.255.0
        gateway 192.168.1.1

whit an IP address different from the IP of the interface of the system (note that here, I’m working on my personal LAN 192.168.1.0/24), and then restart the networking daemon:
$ sudo /etc/init.d/networking stop
$ sudo /etc/init.d/networking start

(If the networking daemon doesn’t restart correcly, do a system reboot)

So now, on your system you will have two ehternet interfaces (you can also create others virtual interfaces, in the same way).
To control your ethernet configuration, run the ifconfig command.

Enjoy!  ;)

Tunneling SSH

If you are in a work space where the outgoing server blocks all the connection, except for the only that it know as safe, but you want to connect to a your HTTP server, to use some services -like Pyload, usually blocked because it use the port 8080-, you only need the port 22 open on the outgoing server (is usually open, for LAN debugs) and the public IP address of your remote server.

Then, you can redirect all the HTTP traffic from the server into the SSH tunnel, like that:
§ ssh user@192.168.1.200 -L 12345:192.168.1.200:8000

This is only an example, so now all the traffic that the remote server (here is 192.168.1.200) usually send to the port 8000 or 8080 is redirect into the ssh tunnel. Now, I can only open my preferred browser, and at the standard address “127.0.0.1:12345” I find my server application!

So note that the port 12345 is a random number, but it must not be a used port number on your system.

So, enjoy!!   ;-)

Auto-completion Bash (Debian systems)

Using an embedded system linux, that I create with an old Debian 6.0.6 minimal armel and the new kernel 3.8.6, on a Freescale i.MX53 board, I discovered that some linux distributions do not have the bash auto-completion pre-installed.

Yeah, is not a great surprise, but it’s a problem when you use a minimal distribution or a distribution that you don’t know..

So, for the Debian systems, you must only install the package “bash-completion”:

$ sudo apt-get install bash-completion

If the bash-completion doesn’t work, you must modify the file .bash_profile in your home directory, by un-comment these lines:

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

If you don’t have the file .bash_profile don’t worry: you must use the .bashrc file.If you don’t have the lines, you only have to add the lines to make the bash-completion work.

USB_Modeswitch (Ubuntu systems)

Few week ago, i bought a Internet Key – 3G modem USB, because the one provided by Vodafone stop working (was a Huawei 3G modem).
The new modem is a TP-LINK 3G modem USB (all the feauters here http://www.tp-link.it/products/details/?model=MA180).
450x270
So i connected the modem to the usb port, but on my Ubuntu i686 the device is not automatically recognized by the Ubuntu Network Manager.
Then, i search on Google, and i found the USB_modeswitch project, that is (as reported in the site) “(surprise!) a mode switching tool for controlling “flip flop” (multiple device) USB gear.

So, from the forum of the project and from other results online, i found a configuration that run on my pc, with Ubuntu 12.04.2 LTS i686 and Unity.

 

1ST STEP: prepare the system

The usb-modeswitch needs the libusb and libudev package to run, and the system must not have another usb-modeswitch installed.

$ sudo apt-get install libusb-dev
$ libusb-config –version

(it is needed at least the version 0.1.12)

$ sudo apt-get remove usb-modeswitch
$ sudo apt-get install libudev0 libudev-dev

 

2ND STEP: download and compile the sources

The program source, device database and device references can be downloaded from the page of the project, from these links:

Then, they must be extracted from their archives and installed with the make command (build by the Makefile present in every folder).
Note that these installations need the tcl package already installed in the system. (otherwise see other methods in README file)

$ sudo apt-get install tcl
$ bunzip2 usb-modeswitch-1.2.5.tar.bz2 && tar xvfp usb-modeswitch-1.2.5.tar
$ bunzip2 usb-modeswitch-data-20121109.tar.bz2 && tar xvfp usb-modeswitch-data-20121109.tar

$ su
# cd usb-modeswitch-1.2.5
# make install
# cd ../usb-modeswitch-data-20121109
# make install

 

3TH STEP: configure the system

Now, the system still doesn’t recognize the device as a modem.
Then, the configure file usb_modeswitch.conf must be modified, with changing EnableLogging=1 (default value is 0) to enable the log of the device.

Then to automate the execution of usb_modeswitch, we need to add a command at the end of the file rc.local.

$ sudo nano /etc/rc.local

sudo modprobe usbserial vendor=0x2357 product=0x0201

 

 

Finally my device is working properly!!!!

The Ubuntu Network Manager recognizes a new 3G device, and shows the option “Enable Mobile Broadband“. So the configuration of the new connection is standard:

  • Edit Connections
  • Mobile Broadband
  • Add
  • select your device in the combo-box
  • Continue, select your Country and Continue
  • select your provider and Continue
  • if it appears the choose of the billing plan, select your plan or write it
  • then Continue and Apply
  • (in some cases, the provider may want the PIN to connect: must be entered in the appropriate field in the editing window of the connection)

 

So I’m finally connected to my provider “Vodafone Italy” (yuppi!!) and I’m connected to internet by the mobile broadband connection!!

Enjoy!!  ;o)

Follow

Get every new post delivered to your Inbox.

Join 26 other followers