Grub rescue

I had triple-boot on my system. Windows 8, windows 7 and Ubuntu and all the boot management done by Ubuntu Grub of course. Almost having all the 3 OS for about 6 months, I started facing difficulties like slowing down, shortage of space, etc and so I decided to delete windows 8.

The process to do that is simple.
on start menu, select run and type msconfig. Once that opens select the Boot tab and in it select the Windows 8 option and click on delete and then click on OK.
I then, deleted the partition holding Windows 8 and merged it with one on the other drives. Now, this leads to en error. The Linux grub manages only the windows 8 and the windows 8 boot loader manages between windows 7 and windows 8. So, when the windows 8 partition was deleted , it corrupted the grub as well.
This lead to the error :

unknown filesystem:
grub rescue> _

This error can be fixed easily.  The path the grub has to be set. So, type the following commands :

set boot=(hd0,msdos6)
set prefix=(hd0,msdos6)/boot/grub
insmod normal
normal

Once all the 4 commands are typed , automatically the grub loads allowing you to chose the OS to boot into.

once the boot options is got.. Boot into Ubuntu and then reinstall the grub using the following commands

sudo update-grub
sudo grub-install /dev/sda

Some times the boot file might not be there on (hd0,msdos6) , in this situation , you can type ls and find out all the partitions
Example :
grub rescue> ls
(hd0), (hd0,msdos5),(hd0,msdos6),(hd0,msdos7),(hd0,msdos8)

So use ls to find the boot folder.
Eg:
grub rescue> ls  (hd0,msdos5)
no file system found
grub rescue> ls (hd0,msdos6)
ext4: file system

So, when a message that come like ext4 or any other file system exist, the boot file is present in that partition. So in the above 4 statements, substitute (hd0,msdos6) with the partition you have found containing the file system.

Socket Programming using TCP/IP

Socket programs are used to communicate between various processes usually running on different systems. It is mostly used to create a client-server environment. This post  provides the various functions used to create the server and client program and an example program. In the example, the client program sends a file name to the server and the server sends the contents of the file back to the client.

Functions used in server program:

  • socket() –    This call creates an unnamed socket and returns a file descriptor to the calling process.
    usage :   int socket(int domain, int type, int protocol)
    Eg:  sockfd=socket(AF_INET,SOCK_STREAM,0);
    here AF_INET means the the communication is over the internet domain.SOCL_STREAM indicates its a stream type of communication and 0 indicates the protocol used is TCP/IP.
  • bzero()–    this call is used set all the values of the buffer to zero.
    usage: bzero(pointer_to_buffer,size_of_buffer)
    eg:  bzero((char *)&serv_addr,sizeof(serv_addr));
    here serv_addr is of the struct type sockaddr_in which has members used to describe the complete address of a system.
  • serv_addr.sin_family=AF_INET;
    As stated earlier the serv_addr has severaal members and the first of it is sin_family and it contains the code for the address family  and is always AF_INET, indicating the internet domain.
  • serv_addr.sin_addr.s_addr=INADDR_ANY;
    here sin_addr has one member s_addr which is used to hold the IP address of the machine its running in, and this IP ddress is got from the INADDR_ANY constant.
  • serv_addr.sin_port=htons(portno);
    here we hav to store port number into he sin_port member and this takes on the network bute order. So, htons() converts the host byte order representation of the port number to network byte order representation.
  • bind() – It is a system call that binds a socket to an address. Here, the address would be the IP address of the current machine and the port number.
    usage : bind(socket_fd, pointer_of_address_its_bound_to, size_of_address);
    Eg:  bind(sockfd, (struct sockaddr *)&serv_addr,sizeof(Serv_addr)_);
    On failure, it returns a value less than zero.
  • listen() –  This call allows a process to listen on socket for communication.
    usage: listen(socket_fd, no_of_waiting_connections);
    so it takes in a socket file descriptor and  the no. of connections waiting while the process is handling a particular connection. so they wait in a blocking queue.
    Eg : listen(sock_fd,5);
    so 5 connections can wait at the max.
  • accept() –  is a system call that causes the process to block until the client connects to the server.
    it returns a new descriptor and all communication should be carried out using the new file descriptor.
    usage: int accept(sockfd,pointer_to_address_of client, addr_storing_size_of_client_address);
    Eg:  newsockfd= accept(sockfd, (struct sockaddr *)&cli_addr,&clilen);
    here cli_len=sizeof(cli_addr); so the newsockfd has the new socket address which will be used for communication.
    So, this command blocks  until the read() of data is complete that is till the client has finished its write().
  • bzero(buffer,4096);
    n=read(newsockfd,buffer,4096);
    this initializes the buffer to zero and then reads the content from the socket (using the newsockfd) into the buffer. Her since the client sends the file name first, the buffer now contains the filename whose contents has to be sent back. The read(), will also block the process till there is something remaining to read from the socket.
  • fd=open(buffer,O_RDONLY) opens the file requested by the client in the read only mode.
  • read(fd,buffer,4096);
    this reads the contents of the file into the buffer. In socket programming, all communications happens using the buffer both at client and server side. With the completion of this read , the contents of the file is residing in the buffer and is ready to be sent to the client.
  • write(newsockfd,buffer,4096);
    this is the final command ehich writes the contents of the buffer( which has the file content) into the socket using the newsockfd which finally delivers it to the client process.

Functions used in client program:

  • connect() –  is a function used by the client to establish a connetion to the server. It takes 3 arguements:
    usage: connect(sockfd, host_to_which_itconnects, sizeof_addr);
    Eg: connect(sockfd,(struct sockaddr*)&serv_addr,sizeof(Serv_addr))<0);
  • The client too like the server uses the write() to send the file name to server and uses read() to read the content of the file into the buffer. It finally uses write(1,buffer,4096) to print the content on file onto standard output.

The full source code and usage for the client and server can be found here.

Setting up and using Github on Linux : A beginners guide

github

 

GitHub is a treasure trove of some of the world’s best projects, built by the contributions of developers all across the globe. This simple, yet extremely powerful platform helps every individual interested in building or developing something big to contribute and get recognized in the opensource community.

This post will be a quick setup guide on Github and how to perform various functions of creating a repository locally, connecting to the remote host that contains your project (where every one can see), committing the changes and finally pushing all the content in the local system to Github.
Please note that this post assumes the the reader is familiar with the terms  on Github such as push , pull requests , commit , repository,etc.

Step 1

download and install git for Linux :
sudo apt-get install git

Step 2

Set up the configuration details for you, as a user of Github:

git config –global user.name “user_name”
git config –global user.email “email_id”

An example for this would be:
git config –global user.name “akshay” [here the “user_name” can be anything.. in my case its akshay]
git config –global user.name “abc@gmail.com” [here the “email_id” should be the ID used to create the GitHub account. In this example its abc@gmail.com]

Read my full post on HowToForge Here.

Join me on Github: https://github.com/akshaypai

The Tor Project : Anonymity Online

As of now, we don’t have any privacy online. It can be the government or websites we browse , keep an eye out for what we do and store that data. And in times like these what we need is a tool to protect us from the exploitation and protect our privacy.

Why should we be worried?
That is because website knows from where a person is browsing and identifies the user. Then starts profiling the user. This helps them to send targeted ads to the user in a hope that the user will buy it. This information can then be sold to others and they exploit it.The result can be unwanted mails , ads and many more.  Now there is a near to perfect solution to it. Its TOR.

Tor helps the user to stay anonymous , provided the user obeys certain browsing rules while using the tor network.

So what exactly is TOR?
The TOR project is a network of servers called the tor network run by volunteers all across the globe.  So when a user is on the tor network , and sends some request, (say a search for a particular topic) then the request is sent through the TOR network and it flows through various path and  finally comes out of some random server present in the TOR network. So the website to which the request was sent thinks it came from the server from which  the request came out of the tor network and not from the user. Hence keeping you anonymous.
How anyone could get into the TOR network –
Getting into the tor network can be done through downloading and setting up the tor bundle. Its mainly a Firefox browser that it configured and modified to connect to the tor network when you open the browser. Tor also allows user to view  blocked website because of its amazing technology.
The bundle can be found HERE.
But one should note that to stay anonymous , the user should follow the rules strictly. Some of them are the tor browser plugins are disabled.Which means most of youtube videos wont play, One cannot use torrent through TOR and also that when a file or a document is downloaded, It shouldn’t be opened before exiting the TOR  network. So read the whole set of detailed Documents from here.

I have used it and its interesting to know the way it works. What is even more amazing is that, the Tor project includes an operating  system called TAILS. Tails is actually Debian Linux operating system which is modified to help its users stay anonymous. Its designed to run off of a pendrive and helps to leave no trace of what the user was doing. This OS can downloaded here. 

So all you have to do is make  a live USB of trails and run it directly from the pendrive each time. Tor or Trails both don’t save history, so it means that all the work when done is deleted, leaving no trace. SO its advisable to store important data in permanent drives rather than on the USB stick itself.

Utilizing the tor network purely depends on the user. It can protect a user if used correctly or sacrifice the privacy if misused. I have  high interest in this project and there is lots to explore  about the TOR network and lots to know about the services it offers. More than following a standard procedure, this is about exploring things, so the more you explore, the more you use it, the more you will start liking it. Give it a try!!

Wikipedia on the terminal , using python

I wanted to get information on my terminal on Ubuntu. y requirement  was that, any  data that i wanted  should be output on the terminal itself. I didn’t want to open a browser each time i wanted some information. And all I needed was the data and not images and videos. So to view the information on the terminal was very convenient and efficient.

When i searched, I was looking for a python implimentstion , i came to know that using Wikipedia API, one can to send a http request to the website as a query action and json format and get the json object. This could be implemented using the request , module in python. So this would give the json object that had the data on the topic to be queried.

The next step was to parse it . And I found that Beautiful Soup can be used to do that so extract only the data. This was one of the best options available . An then the only thing to do was to print the data that is extracted.

I found 2 scripts to do just that. These scripts however dont use Requests module but use urllib and urllib2.
Advantage :
The advantage of using this is that, only a brief summary of the topic under search will be showed. And most of the time it is the only thing we want.

The second thing is that if there are sections in the topic, it will be shown.

Disadvantage :
What this lacks is that, it does not have a good pattern matching for searches, that is if it doesnt ind the exact words in the article it will not be returned. This also happens if each result has multiple result.
Sometimes the data returned is either very less or a lot.

Procedure:

First download and save tehse 2 python files.
wikipedia.py
    wiki2plain.py

Then create a python file and name it wiki.py . Then paste the following script in it.

from wikipedia import *
from wiki2plain import *

lang = ‘simple’
wiki = Wikipedia(lang)
try:
    data1 = raw_input(“enter searh query: “)
    raw = wiki.article(data1)
except:
    raw = None

if raw:
    wiki2plain = Wiki2Plain(raw)
    content = wiki2plain.text
    print content
else:
    print “No text returned”

Save it in the same folder as the other to files and run  wiki.py
Enter the search term and get the results.

Screenshots :

Screenshot from 2014-04-20 22:21:28

Screenshot from 2014-04-20 22:21:06

Android : connecting to AVD using TELNET

TELNET is a A terminal emulation program for TCP/IP networks such as the Internet. Telnet               provided access to a command-line interface on a remote host. Most network equipment and operating systems with a TCP/IP stack support a Telnet service for remote configuration. The Telnet program runs on your computer and connects your PC to a server on the network. You can then entercommands through the Telnet program and they will be executed as if you were entering them directly on the server console. This enables you to control the server and communicate with other servers on the network.

So we can use telnet to connect to the Android Virtual Device (AVD) or the android emulator and perform certain operations that deal with certain environmental values and settings. Here the AVD is running as a localhost. So before connecting, note down the port at which it is running. Generally the top of the AVD gives the port number. Eg. my AVD runs on 5554.

to connect to the  in the terminal use the command:

telnet localhost 5554

if connected successfully  an OK message should be displayed.he various operations that can be performed are-

1. To toggle between the speed of the Internet connection use:
                 network speed edge
    the result is that the network connection is now slow and can be seen on the avd with e marked     with the data pack symbol.
To get the full connection speed type
                network speed full

2.Sending SMS message . you can send to the avd messages :
the syntax is
“sms send <sender’s phone number> <message>”
Eg.   sms send 1234000000  this is good.
This will cause a message to appear in the avd from the phone 123400000 with the message “this     is good”.

3.The charging indicator can be changed to show the amount of charging done including  o for          full. All the input taken is in terms of percentages.

Eg.   power 50  will make the charging to 50%
power 73  will make the charging to 73%

4.  the   help  command will provide a list of  all the operations that can be performed along with        their  option if any. The others include operations like fixing the location(GPS COORDINATE) of        the AVD by using the  geo fix  command, or kill   command to terminate the instance of the            emulator

Here is a summary of the commands and its use:

 help|h|?         print a list of commands
    event            simulate hardware events
    geo              Geo-location commands
    gsm              GSM related commands
    kill             kill the emulator instance
    network          manage network settings
    power            power related commands
    quit|exit        quit control session
    redir            manage port redirections
    sms              SMS related commands
    avd              manager virtual device state
    window           manage emulator window

 

 

SOURCE : Webopedia , coursera

First Update for Ubuntu Dual Boot Installer from Canonical

On 7th jan 2014 the first update to the Ubuntu dual boot installer for touch devices was released. The mail sent by the Canoical team says that this is the first update since Ubuntu and Android dual boot developer preview was announced in Dec 23rd 2013.  Ubuntu Dual Boot Installer is provided as a tech preview for developers who want to run Ubuntu and Android on a single device.Canonical also  has still kept the warning that it is not for regular users as its not a fully stable version. You have to remember that the Ubuntu Dual Boot Installer is still in development and you might experience problems.

Canonical-Releases-First-Update-for-Ubuntu-Dual-Boot-Installer

Here is a complete download and tutorial from the ubuntu wiki : https://wiki.ubuntu.com/Touch/DualBootInstallation

This version however was extensively tested on the Nexux 4 and yet to be tested on Nexux 10. According to the changelog, a warning for unsupported devices is now shown, Ubuntudualboot app is now installed in Ubuntu, and the Install/Download progress bar now fits the screen size in Nexus 10.
Also, Ubuntuinstaller now supports resume for downloading images, and the Ubuntu Installer Application now displays channel chooser on CM 10.2.

this release comes with  6 major bug fixes that can be found here.
And the list of known bugs is listed over here.

 

“Traditional Android”- not the only one anymore

Android versions released by Google has been dominating the mobile market since quite some time. Though mobile manufacturers tweak it a little bit, its mostly like the original release which we can call  “the traditional android”.But now we can see that the windows OS for phones has become quite popular impacting the dominance of android by a tiny little bit. But now, a user gets a whole lot of choices on the OS (other than windows or IOS or traditional android) that we could have had on our mobile phones. Here are a few that I came across :-

Sailfish OS

Jolla recently  their phones running the Sailfish OS. The main motive of using sailfish was simplifying the users work by providing effortless, gesture-based controls, live multitasking and many other features. And being open source, it can be highly customized.

Jolla-sailfish-thumb-620x465_medium

via cdn-static.zdnet.com

3-sailfish-os-ui-594x380_medium

via www.jollausers.com

Sailfish OS is based on the Mer project and QT5 The UI is built using QML and QtQuick2 and wayland.Sailfish OS is claimed to run most of the android apps, though google play doesnaot come by default with the phone there are ways to get the apps and run them on the phone. The Jolla phones are only released in Europe as of now and hopefully will be released elsewhere. For any one who hasnt seen it yet here is Sailfish OS at work:

Jolla – A new beginning (Official)

Ubuntu Touch (Ubuntu for phones)

Ubuntu for phone is a fast and an amazing OS. It provides some features like edge swipes for navigation, Like the Ubuntu dash for PCs it has a favorites screen where the frequently used apps will be stored and also a powerful search to search any kind of content on the phone as well as on the web simultaneously. The user can also reply to Facebook, twitter , text or picture messages right from the notification screen. it has all the native and useful apps pre-installed and many more can be found from the Ubuntu software center (app store).

Phone-naturally-neat_medium

via 2.bp.blogspot.com

Ubuntu-for-phones-screens_medium

via www.xda-developers.com

Firefox OS

The Firefox OS for phones is the Mozilla’s Linux based opensource OS programmed using HTML5 and other web standards. being a community based project , it provides some very good features like the adaptive app search which is not present in the other OS.

Mozilla-mozcamp-firefox-os

via blog.mozilla.org

Geeksphone_medium

via hacks.mozilla.org

Firefox debuted in the ZTE phones but s also available on alcatel one touch devices. All the usual standards apps like facebook, twitter,sporTV, SoundCloud, etc are preinstalled but lots of different apps can be downloaded from the marketplace.

CyanogenMod

Oppo released the CyanogenMod phones and got a go ahead from Google. So the end of 2013 saw the release of Oppo N1 with cyanogenMod in it which is a custom Android version.

This version is much more faster and provides features not present in the traditional Android. Those extra features included are native theme support or support for FLAC format. This Custom MOD has been installed more than 10 million times on android devices and now its officially released. The Oppo Phones also come with a legal version of the android market (google play).

Oppo-n1-1_medium

via dash.coolsmartphone.com

Oppo-n1-607x450_medium

via www.redusers.com

 

WAARTAA : web based IRC client

You may be satisfied with IRC clients like Pidgin, Xchat, mIRC or any other, But now there is a reason for you to change that. Its the new web based IRC client “WAARTAA”. Its got a beautiful UI and appeals instantly to anyone who uses it.

waartaa” is a hindi word which means to communicate, and its apt because its the reason why it was made.
Opensourced under the MIT Licence, this is one amazing project worth giving a try. It is very user friendly ,has a beautiful and bold user interface and very easy to join channels or even create your own IRC server.Being a web based IRC cliesnt as a service it facilitates centralized logging, idling functionality, unique identification across multiple clients.

It is built on the meteor platform. its written in meteor JS and it uses mongoDB and It has also incorporated node-irc which is an IRC client libraary written in JavaScript for Node and also uses a host of meteorite apps.

The User Interface

       waartaa3
(click on image to get a better view)

The Options

waartaa1         waartaa2

Selection_006           Selection_007

 

 

Installation procedure as a local application can be found here.

The question that may arise is why another IRC client when there already exist so many of them?
Well, waartaa has a tons of things to offer that you may have wished were present in existing clients:

  •       while GUI clients work only for single machines, waartaa on a better infrastructure will ensure
    that the user is always connected to IRC while it also captures IRC logs.
  •       It also preovides a central place to store all the chat logs
  •       No matter what device you login from to Waartaa, YOU are always YOU in the IRC and not some
    YOU_, YOU__, etc. which means the it can identify you when you are logged in from multiple devices simultaneously.
  •       Being a web service, it runs flawlessly on the browser of any device making your experience comfortable

Sourcecode available HERE.

Installation tutorial and procedure for waartaa here.
Waartaa is not yet deployed and will  soon be , but as of now you can run it locally as of now and try it out. The sourcecode and the setup instructions can be download from the github page.
So fork it and customize it as you want your client to look like. So do try it out, this might  just be the thing you always wanted.