IMHO opinion editing the shadow
file is unnecessarily complicated and risky (although I believe the post above describes it correctly). I outline below two methods for simply using the passwd
command. I had written the contents below and then I got delayed as a result of (ahem) "user error."
For simplicity (for me) I am leaving it as I originally wrote it. Just realize I had written it before seeing the above post.
Welcome to LQ!
Do you mean the root
password? Because you mentioned not setting up a user account, I am going to assume so ...
Just a note for future posts: It is a good idea to let us know what distro (name and version) you are using. Sometimes it makes no difference; frequently it does.
If you have the ability to get into single user mode w/o the root password, that would be the simplist way. You can tell the system to boot to single user mode (Ubuntu, and maybe others, call this recovery mode) by putting the numeral "1" or the word"single" on the kernel command line. Some distros already have an entry for this in the GRUB menu.
If you can't get into single user mode (because it requires a password you don't know), boot up from a live CD. Become root
if you are not already. (On some live CDs you can use sudo su
.) Mount your root partition and then chroot
to it. (I am assuming sda1 is your root partition. Adjust to need & taste)
Depending on which live CD you use, the first step may be unnecessary.
mount /dev/sda1 /mnt/sda1
Whichever method (single user mode or live CD) you used you can now type:
It will prompt you for the new (root) password twice. If the you enter the same password (i.e. make no mistakes) it will tell you that "all authentication tokens" have been successfully updated, and you should be good to go.
EDIT: In the instructions above, I assumed /usr was on the root partition. This is probably true. But if
/usr is on its own partition, then that partition must be mounted for the above methods to work since passwd
is in /usr/bin. In the second method, /usr should be mounted before
chrooting. I wouldn't worry about this unless you get a "command not found" when you try to run passwd