Setting a default root password

Under certain circumstances it might be convenient to set a default root password. For example when deploying Gentoo cross-platform trying to chroot in the common way may return an. If the respective entry in the Knowledge Base does not apply chances are that using a QEMU user chroot instead of the standard procedure is indicated. In that case circumventing the necessity of chrooting may spare a lot of efforts. Setting a default root password is integral to that circumvention.

To set a default root password the file needs to be manipulated.

Hash the password
Since passwords may not be stored in plaintext use to convert the password:

In this example the string corresponds to the password "gentoo".

Option 1: Edit shadow by hand
The resulting string needs to be placed in. In that file replace the line beginning with  with the line shown below, substituting  with the string obtained before.

In case of the example above it would look like that:

Option 2: Use to manipulate
The resulting string needs to be placed in. First escape Basic Regular Expressions in the string provided by the command above, that is precede each of the characters   by.

In the following command substitute with that modified string.

In case of the example above this would look like that: