16 October, 2014

How to share internet connection in Ubuntu to a Raspberry Pi over LAN cable


Before we dig deep on this subject, I assume we got a Laptop connected to the internet over wifi and we are running Ubuntu on it. Now connect the Raspberry Pi (running raspbian os) to the laptop using a LAN cable. 




To share the internet connection open the Network Manager application and edit the Wired Connection.






 
 
Click on the IPv4 Settings tab and select the Method -  Shared to Other computers.

Once the above steps are complete reconnect the network to get the connectivity over the raspberry pi. 












Read rest of entry

30 September, 2014

Install Raspbian (Debian Wheezy) OS on Raspberry Pi using Ubuntu


Hope you have seen my earlier posts regarding the raspberry pi over this link.This  post is about setting up Raspberry pi with Debian Wheezy on it. I am assuming that you have a Ubuntu/Debian running laptop already available. For those who are not yet in this universe (I mean using windows) please follow this link

Get the raspbian OS image from the official website. You can get the files either by the torrent link or through the direct download link.


If your sd card already contains a linux distribution, follow the steps mentioned in this link to factory reset the card

  • Run df -h to see what devices are currently mounted.

  • If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer.

  • Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card; it will be listed as something like /dev/mmcblk0p1 or /dev/sdd1. Ideally if you are plugging your card into laptops card reader using it's adapter device label will be /dev/mmcblk0p1.On the other side if the card is connected to a usb card reader, device name shown will be /dev/sdb1 or /dev/sdc1 or /dev sdd1 etc... The last part (p1 or 1 respectively) is the partition number but you want to write to the whole SD card, not just one partition. Therefore you need to remove that part from the name (getting, for example, /dev/mmcblk0 or /dev/sdd) as the device for the whole SD card.

  • Now that you've noted what the device name is, you need to unmount it so that files can't be read or written to the SD card while you are copying over the SD image.

  • Run umount /dev/sdd1, replacing sdd1 with whatever your SD card's device name is (including the partition number).

  • If your SD card shows up more than once in the output of df due to having multiple partitions on the SD card, you should unmount all of these partitions.

  • In the terminal, write the image to the card with the command below, making sure you replace the input file if= argument with the path to your .img file, and the /dev/sdd in the output file of= argument with the right device name. This is very important, as you will lose all data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card as described above, not just a partition of it; for example sdd, not sdds1 or sddp1; or mmcblk0, not mmcblk0p1.

    cd /path/containing/extracted/OSimage/previously/downloaded

    sudo dd bs=4M if=2014-09-09-wheezy-raspbian.img of=/dev/sdd

  • Please note that block size set to 4M will work most of the time; if not, please try 1M, although this will take considerably longer.

  • The dd command does not give any information of its progress and so may appear to have frozen; it could take more than five minutes to finish writing to the card. If your card reader has an LED it may blink during the write process. To see the progress of the copy operation you can run sudo pkill -USR1 -n -x dd in another terminal. The progress will be displayed in the original window and not the window with the pkill command; it may not display immediately, due to buffering.

  • Run sync; this will ensure the write cache is flushed and that it is safe to unmount your SD card. 
  • Remove the SD card from the card reader.

     
Read rest of entry

27 September, 2014

How to remove existing OS installation and reset the size of Raspberry Pi's SD Card

To remove existing OS installation and reset the size of Raspberry Pi's SD Card we are going to use one of the simple partition editor - gparted in Ubuntu/Debian.

Insert the SD Micro SD card that may or may not contains the Raspberry Pi's operating system into your laptops card reader slot. I am assuming that you got a Raspbian OS installed on the SD card during the life of this post :).

On the top right corner of the gparted, choose your SD card properly. You can identify your card using the size in Gigs(14.84GB) or the by checking for a disk name that starts with pattern - mmcblk*. If you choose wrong disk here in this menu, I will not be responsible for anything that sounds like "I lost my personal files" or "I lost my movies" or "my OS is crashed" and so on. See the below image that have the right selection.


Now unmount earch partition by right clikcing on them, if it is already mounted. Ideally the new versions of Ubuntu will mount the partitions automatically unless otherwise you tweak it to not do so.


Once the partition is unmounted, you are ready to delete it.
 
All the changes made so far will be, written to the memory device when the apply button is clicked as in below image.







Read rest of entry

How to install gparted (partition editor) on Ubuntu 14.04 LTS / Debian wheezy / Raspbian

Here is how to install one of the coolest partition editor for  Ubuntu 14.04 / Debian wheezy / Raspbian

Gparted a GUI based application that helps to work with partitions on your memory devices. It is packed with many features like
  •     Create partition tables, (e.g., msdos or gpt)
  •     Create, move, copy, resize, check, label, set new UUID, and delete partitions
  •     Enable and disable partition flags, (e.g., boot or hidden)
  •     Attempt
  •     Create space for new operating systems

GParted works with the following storage devices:
  •     Hard disk drives (e.g., SATA, IDE, and SCSI)
  •     Flash memory devices, such as USB memory sticks and Solid State Drives (SSD’s)
  •     RAID Devices (hardware RAID, motherboard BIOS RAID, and Linux software RAID)
  •     All sector sizes (e.g., devices with 512, 1024, 2048, 4096 byte sectors and more)


Update your software repository listing using the apt commands from the terminal:

sudo apt-get update


 
Now install gparted using the below given command

sudo apt-get install gparted

 
 


Once the installation is complete, launch gparted using the following command and provide the root credentials


sudo gparted



Read rest of entry

17 September, 2014

Unboxing Raspberry Pi B+

And raspberry pi is home yesterday... Here are some snaps  while i unboxed it.


 







Read rest of entry

16 September, 2014

Raspberry Pi & accessories - purchase guide in India


All the Raspberry Pi accessories are home yesterday. In India there are lot of online purchase options for raspberry pi and accessories from leading online sellers like ebay.in, amazon etc... I would like to tell you from where I collected it rather than where all it can be purchased( That will be gross, since there are whole lot of providers around here)

 


Raspberry Pi B+ SoC

Both these sites sell comparitively less priced B+ boards than ebay/Amazon during the time of my purchase. I chose CrazyPi and got the delivery within a week of the order.


Clear Case for B+

There are better cases available in amazon and CrazyPi.com. The one that I chose was cheaper though good looking. B+ got two LEDs on the board with red and green color. FYI, A transparent/acrylic  case will defenitely look geeky, than the clumpsy plastic case


SD card
Out of the a whole list of SDcards that Pi can run i just chose - Sandisk Ultra microSDHC 16GB Class 10 Memory Card with Adapter. If you need to know the entire list of SD cards supported by the Raspberry Pi, following page will be handy - http://elinux.org/RPi_SD_cards


USB Wifi Dongle

This is seems to be the cheapest wifi dongle that the B+ can run. Need some work around for installing the firmware for the B+, still range is almost similar to my Xperia mini's antenna.

If you are looking for some other options here is your handbook - http://elinux.org/RPi_USB_Wi-Fi_Adapters



USB BlueTooth dongle

Initially I worried whether it will get detected by the rPi, however even during the boot itself you can see the trace of this dongle getting noticed by the Pi.



HDMI cable (if your tv supports hdmi)

Get a cable that is fast and long enough. Ebay got more options than other stores


HDMI to VGA adapter (optional)
Ordinary HDMI to VGA converters dont work with the Pi. You can get one from carzyPi store that have Digital to analog signal conversion chip. This adapter is completely different from the regular hdmi vga converters available in ebay.


5V/750mA Power adapter ( aka your smartphone's charger)

If you want a dedicated power adapter, a NOKIA Lumia's power cable will be the easy option that can output 5 Volts and ~750 mA. In all other cases your smartphones charger will be the alternative.



Read rest of entry

What happened when I heard about a raspberry Pi



The enthusiast inside me was just sleeping for a while (possibly around 3 years due to the damn corporate IT culture). And technically that was the reason why there wasn't enough posts recently. Suddenly last month on a trip to Coorg with @asuthoshjg & @nikhilkv, I heared about this little nasty motherboard from @asuthoshjg. The whole reason for the raspberry pi to hit our conversation was just my concern about a 4GB SD card in dslr that will easily run out of memory before we reach Coorg via Mysore. And pi just got hooked enough into my brain that browsing about it was the first thing that I did when reached back home after a sleepless night of driving and hunger.

The one best paragraph that explains everything about the pi in their community website is added below.

The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It is a capable little computer which can be used in electronics projects, and for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn how computers work, how to manipulate the electronic world around them, and how to program.


It was one of the interesting things that I heared recently apart from the understanding that Saturday and Sunday are holidays at my workplace (sigh - literally). The another thing that increased my anticipation was that pi was available for online purcase at lot of sites. And I started getting excited about a pocket cpu that is powered by ARM6 700 Mhz processor with 512MB RAM, 4 USB ports, ethernet port and hdmi out at 4k-5k along with accessories. The plan was to replace the  plan of purchasing a vaccum-cleaner ( countless requests from my mother since last months) with the raspberry Pi. 


The funniest part was, Pi will just improve the count of number of computers (used and unused) at my home by 4. Four is a good number, by the way. It was not the Pi alone, but it was the enthusiasm and same old interest to these kind of stuffs when i was at my college, that is coming back to home along with the Pi soon.


Hopefully another post will be ready soon in a week when I get my hands on the Pi...




Read rest of entry

17 August, 2011

setup lamp server on debian/ubuntu || the easiest & the best way


The LAMP server is the commonly abbreated for Linux Apache MySql PHP server. This is a platform where web pages can be build/test/run using linux.

So setting up your LAMP server includes installing all those above said packages and configuring them to work together.

You can use either terminal or synaptic package manager to install these packages [and should have a working internet connection]. Anyway we may have to use the terminal for configuring them. So better move with the Terminal [Applications > Accessories > Terminal] itself.

1. Install Apache server

------------------------------
Below command will install apache server in your system


$ sudo apt-get install apache2

when the installation finishes, test weather it's working by pointing your web browser[firefox / chrome . . . ] to the following web address.
http://localhost/  

You should see a folder entitled apache2-default/. Open it and you will see a message saying something like > "It works!"

2. Install PHP

- - - - - - - - - - - - -

copy-paste the command given below onto a terminal and hit the enter key.


$sudo apt-get install php5 libapache2-mod-php5

While PHP installation finishes, restart the apache web server to make it compatible with apache using the following command.


$ sudo /etc/init.d/apache2 restart

testing PHP

To ensure there are no issues with PHP let's give it a quick test run.

Step 1. In the terminal copy/paste the following line:



$ sudo gedit /var/www/test.php

This will open up a file called test.php.

Add the following line into the test.php, save and close the file.


  <?php
      phpinfo();
  ?>


Now open you're web browser and type the following into the web address:



http://localhost/test.php


Note : You can change the location of the Document root [by default it is /var/www/] by reading this article.

Install MySQL
- - - - - - - - - - - - - - 

open up the Terminal and then copy/paste this line:


sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql


install phpmyadmin
-------------------------

 

sudo apt-get install phpmyadmin

Now just restart Apache and you are all set!



sudo /etc/init.d/apache2 restart


That's enough! your LAMP server  is ready, and now you can can move up with your pretty codes >>
Read rest of entry

07 July, 2011

Change the DocumentRoot of Apache webserver (/var/www) in Debian / Ubuntu

The document root (also called as the web root) of the Apache web server is located at the /var/www directory by default. Document root is the place where we find all the web pages and server scripts. These files are loaded on the browsers when we type in a particular url to point to that server. 

The /var/www directory doesn't allow access for a user who doesn't have the root permission. It's a headache task to switch to the root mode by typing in the root password everytime even though you know the password, since you may have to change your webpages or scripts during its development stage  very frequently. So a better idea to avoid this problem is to change the default Document root directory to some other location which doesn't require root permission for access.


Change it dude !!!
- - - - - - - - - - - - - - - - - -#

Inorder to change the document root,

#1. Make a directory somewhere inside your home directory to use as the Document root. (not necessarily be home... you can make it anywhere). I named it 'www'

$ mkdir /home/jo/www

#2. Now we have to edit the one of the configuration file of the Apache webserver. The file is located @  /etc/apache2/sites-available/default (requires root permission to edit it).

$ sudo gedit /etc/apache2/sites-available/default

The file will be opened up in the gedit text editor. Now you have to edit the DocumentRoot directive in this file. Replace the /var/www with the /path/to/your/new/document/root in the lines 4 and 9 as shown in the figure below.


#3. Restart the apache webserver.

$ sudo /etc/init.d/apache2  restart



Now test it !!!
- - - - - - - - - - - - - - - - - -#

#1. Create a html/php file inside the Document Root directory (mine is @ /home/jo/www).

#2. Take the terminal and navigate to the Document Root directory (using cd command). Use chmod command given below to allow read+write+execute permission to all.

$ chmod 777 *

#3. Take your web browser and type in http://localhost and hit the enter key! The apache server will load the contents of your Document Root directory as in the figure.


Hope you have done it right!!!


Read rest of entry

Use the Debian Squeeze DVD/pendrive as a package repository

The Debian Squeeze DVD contains many application level packages which are not installed during the base operating system installation. Only core packages are installed during the basic Debian Operating system installation. For example the DVD is loaded with the graphical display managers such as Gnome, KDE and XFCE, but during the installation you can select only one among them.  There are a lot more stuff in the dvd, such as vlc media player, phpmyadmin, mysql etc. Here I am sharing how i used these Debian squeeze DVD as a repository to install those packages.

Adding the dvd to the repository
                 --------------------------------------------------

Take the terminal and type the following

$ sudo apt-cdrom add



This will add your DVD to the repositories list. 


For those who are using the pendrive as the installation media, pendrive should be mounted on the /media/cdrom directory. This can be done in two steps.


#1. Plug in the USB pendrive, then the new block device will be added under the /dev directory. We have to find this block device location for mounting and using the device. Use the following command to detect the block device's filename (selected in the image).
$ sudo fdisk -l


#2. Mount the block device into /media/cdrom.  

$ sudo mount  /dev/sdb1  /media/cdrom/


#3. Add the cdrom to the software repository list, as described earlier in the  case of the DVD.

$ sudo apt-cdrom add


Installing Packages
-------------------------------------
Now install the packages using the apt package manager. Check the sample below :- 
$ sudo apt-get install vlc

Thatz up...This trick will work for Ubuntu also...
Read rest of entry

31 May, 2011

Downloading online flash games and playing it offline in ubuntu 11.04

Flash games are always the right option whenever you feel bored and frustrated sitting infront of pc. Here is a cool trick for downloading all your favorite flash games from any websites that we play usually online. Along with this i am just including the installation of a flash player for playing the .swf files we are going to download ( a browser installed with flash plugin is always enough, though just use it... ).

Usually all the flash games are embedded in the html page so that the browser first caches and loads the application. So the trick to find out the correct url of the .swf file (of the game) varies from website to website.. Dont worry we will go through some eye popping tricks :P

Installing swf player in ubuntu
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Install swfdec-gnome package with your terminal as follows. U can use synaptic or Ubuntu software centre to install it.  


$ sudo apt-get install swfdec-gnome
 

#   Catching the fish           <------ geeky way
-----------------------------------


Now it is the time to find a cool flash game that you call 'addiction'. For the timesake i am taking the famous game called 'appleshooter'. You can find it on the officegamespot website. Wait till the browser loads the game. Now just take the source code of the page using View => Page Source from the browser (or hit Ctrl + U). In the source page find the pattern ".swf" (Hit Ctrl + F and type .swf).


If you find this pattern as a part of a url then that is the original location of the swf file which we see embedded in the html page. Then copy paste the url ending with .swf on a new tab on the browser to load that game alone. If you dont get a url, we need to use some kind of guess work to find it out.
 

Here i am pinning the screenshot of page source of the appleshooter game on officegamespot website. They dont uses direct url to the .swf file in the page source.



I guessed the url to the .swf file from the above picture from this field <a href="arrow_shooter_03.swf" .....> and tried replacing the tail part of the url,  


http://officegamespot.com/officegames/appleshooter.htm 
with  
http://officegamespot.com/officegames/arrow_shooter_03.swf 
Hi hi, that worked !!! the flash game alone loaded in the browser.

Now save the swf file to your machines hard disk for using it offline. For this just go File > Save Page As from the browser itself. So we have done it almost, whenever you want to play the game just go to that folder and open the file with swfdec flash player.




   

#   catching the fish          <-------- firefox guy 1
----------------------------------


Here is another trick to findout the url to the .swf file. After the browser loads the game completely, open a new browser tab and type about:cache?device=disk in the address bar and hit the enter key. Now Find the pattern .swf file in this page. Copy the url of the one that is the flash game among the urls matchin the search for .swf pattern. Open another tab and paste the url (to .swf file) to load the swf application alone in the browser. Use File > Save File As to save it to your hard disk. Later you can play the game by opening the downloaded swf file with swfdec player or with any web browsers...




#   catching the fish        
<------- firefox guy 2
----------------------------------

Another methode to get a copy of the .swf file of the flash game is to search on the browser cache for the file. You shold have to load the game on the browser to make this trick work. After loading the game completely in the firefox browser (no need to play till the last level to get the file completely !!), open a new tab and type about:cache in the address bar and hit the enter key. 




Copy paste the value of Cache Directory under Disk Cache Device to the terminal after typing nautilus.

$ nautilus /home/jo/.mozilla/firefox/tu9q54ls.default/Cache

Then the cache directory will open up. Just sort the items by Modificaton date and you can find the .swf file among the recent files. Copy it from the cache to some other directory, other wise the file will be lost when the browser tab is closed or loaded with some other pages. Now open it with the swfdec flash player to play it anytime like a standalone application..

   
#
  catching the fish   
<------- for the lazy guys
---------------------------------
If you are too lazy to spend time on above tricks, then there is an option... Use the google's search engine to find the swf file for you, so that you can just download and play it. Just type in the search box like this pattern without quotes 'appleshooter filetype:swf'.


Copy the direct url to the swf file from any of the search result. Load it in a new tab. Save it using the browser itself. You can also use a terminal command called wget to download the files.

$ cd your/games/directory
$ wget http://vc02.free.fr/media/kangg/kang.swf


Hope you got the game, now play it ...






and Hope you like the post !  Comment on !! share your ideas ....!!!
Read rest of entry

20 May, 2011

Setting up local dns cache and public dns address for "lightning" speed browsing in Ubuntu


When it comes to internet, reasonable speed is always an uncomprimisable thing. That may be a crucial reason for making you sit infront of your machines for hours and days. So the lightning speed can be achieved with your ubuntu box in two ways. They are 
  • Use faster and free domain name servers like google's pubic dns or OpenDNS (first throw the one provided by your service provider). Hope you will check one of my past article written in Crack Bytez.

  • Maintain a local dns cache in your machine itself.  So that you can do a good amount of address resolution for frequently used websites within your machine itself, and that saves a reasonable amount of time.

Here i am planning to bring both of these techniques together in a simple manner. Though there are many applications for local DNS caching in ubuntu [ such as dnsmasq, pdnsd, bind9 ] are available, bind9 seems to be a good option for me...

Starting with BIND9  DNS server in Ubuntu

Bind9 (Berkly Internet Naming Daemon)  is the most widely deployed DNS server. Bind9 is available in the ubuntu main repository itself. So you don't need to add some additional repository for installing it. Use the following command line or search for 'bind9' in Synaptic package manager to install it. 

$ sudo apt-get install bind9

Bind9 allows different type of configurations, and our point of view is on configuring it as a caching server. In this configuration BIND9 will find the answer to name queries and remember the answer for the next query. This can be useful for a slow internet connections especially based on mobile internet. By caching DNS queries, you will reduce bandwidth and (more importantly) latency. It increase network performance by caching IP addresses of commonly visited websites instead of retrieving them from the public DNS servers maintained by ISPs at each request.

Configuring the BIND server 

#  First you have to set your machine's address (127.0.0.1) itself as the primary dns address.  This can be done with the help of Network manager or by editing the /etc/resolv.conf file in your ubuntu box. Check the screenshot below..

  • using Network manager:: select the connection and click on the edit. Then choose the IPv4 settings tab and add 127.0.0.1 to the DNS servers field.

  • editing the resolv.conf file:: If you are using DHCP then you may have to edit the resolv.conf file every time you connect to the internet to make bind work properly.



Now change the bind configuration file to add some external DNS servers for resolving a new address that is not cached on your local cache at that time. If you are not adding an external dns server, then it will not be possible to resolve a new address request comes from the browser.  Here i recommend google's public dns or OpenDNS addresses to add in the BIND configuration file. This servers may be sometimes faster and reliable than your ISP's Domain Name Servers. You can find the best DNS server applicable for you by checking in this post. Here is how i have added it

#  First open the file 'named.conf.options' 

$ sudo gedit /etc/bind/named.conf.options

#  Now uncommend the section 'forwarders'. Replace the '0.0.0.0' with the dns server address applicable to you (Check the figure).

#  Restart  the BIND server:

$ sudo /etc/init.d/bind9 restart

 

Thatz it. We are almost done. Now use the dig command to see the change in speed. If you "dig" a domain name multiple times you should see a drastic decrease in query time: between the first and second query. This is due to the server caching the query. See what happened when i dig twitter from my terminal three times concecutively. See the change in the Query time.

$ dig twitter.com

                                                        

Time is up. Go Applications > Internet > firefox and experience the lightning speed...

Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger