As far as i remember while installing ubuntu,the installer didn’t ask me for the root password. It asked me to create an account just before preparing for the first time use.There i specified a username and a password.I use this password to log onto my ubuntu machine. I had to install something which gave the following error :

What could be the problem ? when i enter as root an mention the password,it says auth failure. How
Perhaps better suited on SuperUser…
Text taken from ubuntu-help
By default, the Root account password is locked in Ubuntu. This means that you cannot login as Root directly or use the su command to become the Root user. However, since the Root account physically exists it is still possible to run programs with root-level privileges. This is where sudo comes in – it allows authorized users (normally "Administrative" users; for further information please refer to AddUsersHowto) to run certain programs as Root without having to know the root password.
This means that in the terminal you should use sudo for commands that require root privileges
So, in your case, use
sudo gem installinstead