Saturday, August 1, 2009

Ubuntu root password

Ver este artículo en español.

Ubuntu is different from other GNU/Linux distributions, in the sense that by default, root user does not have a password. In fact, if you take a look at /etc/shadow file, the root line looks something like:

root:!:14293:0:99999:7:::

showing not only that the root user has not password, but also that is locked.

First of all, I should say that Ubuntu is a great distribution, but it is designed principally to desktop computers. As for that, you generally do not need to log in as root user; instead, the times that you need to make superuser tasks, that you only can do if you have the "Administer the system" privilege, the OS ask for your password when in Gnome, and in a console you have to prefix the command with the command sudo.

Given that explanation, and if you still want to set a password for the root user, you will have to access to a console with root user. To do that, you can't use the su command, because as we already know, the root user has not password. Instead, you may use (being logged with an user with "Administer the system" privilege):

sudo su -

That command will ask for your password, and then (of course, in case you have typed your password correctly :)), you are logged as the root user in that console. After that, you can change (or better said, set) the root password with the well know passwd command. Having done that, you can use the root user to log in to the system, as in any other distro.