Logging into Ubuntu as root

There comes times when you simply need to login as root to Ubuntu.  One of those times came this morning when we were trying to use an automated tool to convert a physical machine to a virtual one.  Obviously by default the root account is locked down in Ubuntu, however, in this instance at least (running Ubuntu server) it turned out to be fairly simple to get around this.  It turns out that by default access to the root account is not locked down the only problem is that you don't know the password. In linux it's fairly easy to change the password and it's as simple as logging in locally or remotely and running this command.

sudo passwd root

When you see the prompt saing "Enter new UNIX password" enter the password you want to use and confirm it.  If you're not running a GUI version of Ubuntu then you're done. Otherwise if you're running Gnome then you will have to make one other small change. Simply type

sudo nano /etc/X11/gdm/gdm.conf

Obviously you can replace nano with the text editor of your choice.  Now alter the line that says "AllowRoot=false" to "AllowRoot=true".  Save the file and you should now be able to login.