Posts Tagged ‘Linux’

ABC to hack root password in Linux !

August 25, 2009

The following link has the detailed instruction along with snap shots

http://somnathsingh.wordpress.com/2009/08/20/how-to-hack-root-password-in-linux/

Note this technique only works for Fedora and Red Hat !!

Hopy you find it interesting !! 😀

ABC to Convert Integers to Strings in C++

June 23, 2009

I was solving a problem in TopCoder. It required a conversion of  integer to a string. This is simple in Java but a little complicated in C++. So, I am jotting down here some of the link that helped me. I will also try to make a mention of the problem associated with them.

The first one – itoa. Well, itoa considered unsafe to use this in C++. You may get an error like ” itoa was not declared in the scope “. I got stuck with the same error. It was then I started searching for solutions. The link following is about itoa. Note that, itoa doesn’t work in TopCoder.

http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/

The next link use boost and a string stream. Again, the header file “boost/lexical_cast.hpp” is not detected by TopCoder.

http://ubuntuforums.org/showthread.php?t=271660

So, I feel, more or less the best way is to have you own customized code.

string convertInt(int number)
{
    if (number == 0)
        return "0";
    string temp="";
    string returnvalue="";
    while (number>0)
    {
        temp+=number%10+48;
        number/=10;
    }
    for (int i=0;i<temp.length();i++)
        returnvalue+=temp[temp.length()-i-1];
    return returnvalue;
}

The following link has more information about it.

http://www.cplusplus.com/forum/beginner/7777/

If you have any doubt, post in them as comments.

In Java, you can go about with some code like the following. Note, ‘s’ is a String and ‘a’,’ b’ and ‘c’ are Integers.

s = a + ” ” + b + ” ” + c;

Though something like above is possible in C++, it requires ‘a’,’ b’ and ‘c’ to be Strings.

Happy coding ! 🙂

boost/lexical_cast.hppboost/lexical_cast.hpp

ABC to use grep to search for a word and also to get its line number

June 18, 2009

Wondering about the big title…. lolzzz… will it has a meaning….

First, The command :

cat filename | grep -n search_keyword | less

Say, you have a file called filename and you want to search for a term called search_keyword. The -n stands for number. It will print the line number where the search_keyword is found. | less is just a normal utility that lets you scroll up and down if you have the output (of the above command) running for more than a page.The following are some example –

Say, we have a file called abc.txt with the following contents:

A  :  mangoes are tasty fruits.
      Do u like mangoes ?
B  :  No, I don't.
      I like apples.
A  :  But I like mangoes more than apple.

From the shell (terminal), execute the following command.

cat abc.txt | grep mangoes

You will get the following output

A  :  mangoes are tasty fruits.
      Do u like mangoes ?
A  :  But I like mangoes more than apple.

When you added -n to the above command i.e.

cat abc.txt | grep -n mangoes

The output looks like this , notice the line numbers :

1:A : mangoes are tasty fruits.
2:    Do u like mangoes ?
5:A : But I like mangoes more than apple.

I hope everything is clear !

ABC to install Gnuplot SuSE 11.1

June 10, 2009

GNU Plot is not installed in SuSE 11.1 by default. But, the  installation is fairly simple. It is going to take less than a minute !

The easiest way to install Gnu Plot is to use the Installation disk. Just a package needs to be installed ! The steps are as follows –

1. Go to YaST Control Center. Select ‘Software’ on the left panel and then open ‘Software Management’ on the right.

2. Make a search for ‘gnuplot’.

3. The is only one package for gnuplot. Check mark that. Have a look at the  snap if something wasn’t clear.

YaSt Software management

YaSt Software management

4. Click on Accept and the Installation start. Remember to insert the Installtion disk when propmted. :P

Gnaught – A new software !

May 31, 2009

The open software crazy has gone to reach heights. The community has millions of developers and they keep inventing some new software and promote it. This in turn draws more people to the community and this is exactly why it is done. Yes.. you have got it right, a Viscous Circle.

Adding flavour to this is the software Gnaughty.  I am not going to describe what it is or how to install it. All I am going to tell is that it is a Open Source Software. Other required information are given in the link following.

http://www.gnomefiles.org/app.php/Gnaughty

I guess you have seen it ! lolz…  thinking something… go on keep thinking…

Credits to Abhishek Srivastava for discovering it !

Windows is a better OS….

May 6, 2009

Does any other OS provide this way of entertainment ?? 

 

Windows is a Better OS !

Windows is a Better OS !

Old is Gold !! 😀

http://tinyurl.com/dap5oz

Download and Install log4j / Log for Java

May 1, 2009

Log for java aka log4j is a library. Its a small software that need to be downloaded an installed. The installation which I am going to illustrate if for Linux and a similar procedure can be followed for windows. It can be downloaded from the following link –

http://www.apache.org/dyn/closer.cgi/logging/log4j/1.2.15/apache-log4j-1.2.15.tar.gz

Download the tar file and extract it using the following command

tar -xvvzf apache-log4j-1.2.15.tar.gz

Move the for apache-log4j-1.2.15 to the a location of your choice. But I recommend you to put it in a folder where you have installed java (say you have moved the extracted the folder to /usr/java/). Now, the jar file log4j is inside the folder. The path should be

/usr/java/apache-log4j-1.2.15/log4j-1.2.15.jar

After this there are two ways to make it recogniseable by you java program. One is you need to set the CLASSPATH. The second and the best alternative is, you could import that jar file. I guess most of you use NetBeans or Eclipse for java programming. So all you need to do is to imort this jar file and it will be recognised by you package. If you want to know how to use logger function, read the following manual

http://logging.apache.org/log4j/1.2/manual.html

Greatest Myths about Open Source Revealed !!!

March 9, 2009

My friend Abhishek Srivastava has tried to answer some of the greatest question that explains the myths and misconceptions about Open Source Softwares and Technologies. Here are the question…..

Does Free and Open Source means Zero Cost?

Is Free and Open Source Software’s always related with LINUX?

So why we are paying for software’s even if we want to use Windows only?

I guess you will find the answers intersting. I guess he was apt with his answers. He must have done a lot of research work before getting those key answers. I really enjoyed reading it, hence with his permission posted a part of it here so that more people get to read it.

Hats Off Abhishek!!! 😀

http://tinyurl.com/b4fxkw

%d bloggers like this: