Monthly Archives: January 2011

Speed your internet browsing on Ubuntu using local DNS Cache

Use these steps to speed your internet browsing requests on Ubuntu, by enabling local DNS cache :

1- Run this command to install dnsmasq package

sudo apt-get install dnsmasq

2- Modify the file :

sudo gedit /etc/dnsmasq.conf

change the line :

#listen-address=

To :

listen-address=127.0.0.1

3- Modify the file :

sudo gedit /etc/dhcp3/dhclient.conf

Ucomment the line :

prepend domain-name-servers 127.0.0.1;

4- Add the DNS 127.0.0.1 to your connection through your connection manager

Your DNS servers should be :

127.0.0.1,8.8.8.8,4.2.2.4

5- Restart your connection

sudo /etc/init.d/networking restart

To check if it is working issue the following command twice:

dig php-architect.com | grep 'Query'

first response will be like :

;; Query time: 96 msec

run the previous command again

dig php-architect.com | grep 'Query'

Response now should be :

;; Query time: 0 msec

This will speed your browsing especially in pages with many HTTP requests.

Backup or Export, Compress and upload mysql database to remote host

This is a handy command that i use to backup or export, compress and upload a mysql database to my remote host, very handy when you wanna upload your development database to the remote host after some changes.

/usr/mysql/bin/mysqldump --opt -uUsername -pPassword Databasename  | gzip -c | ssh -q user@remote-host.com 'cat > ~/Databasename.sql.gz'

Replace the following :

  • /usr/mysql/bin/mysqldump : The path for mysqldump on your localmachine
  • Username : Username for local mysql database.
  • Password : Password for local mysql database.
  • Databasename : Name of the database to export.
  • user@remote-host.com : the user and the IP or the address of the remote host.

the above command will upload the compressed database to your home directory on the remote host, to change the directoy, replace ~/ with the path you want.