On a properly secured system that shouldn't be (easily) possible
There are some ways, anyway, if you have
not set a bootloader password and can thus boot into single-user mode (get a root account without password).
1) Boot your machine; at the bootloader type
or add number
2 at the end of the kernel line; I recall either of those should boot into the single-user mode. When it does, you will be log in as root without password asked (this is why
you must set a bootloader password, at least)
2) Once in single-user mode and as root, first try simply issuing
If you are
not asked for your old password, but just the new one, simply fill it in (twice) and after reboot you should be able to log in with that password. In this case omit the next part 3; if you however
are asked for your own password, do this:
3) open a text editor (here
vi) and start editing your
/etc/shadow file (only accessible to root; has encrypted password information inside). Some older systems might not have this file, in that case you would simply edit
/etc/passwd instead, just the same way as you edit this file now (
/etc/passwd on newer systems has no encrypted passwords as it's world-readable, it has only the letter
x where
/etc/shadow has the encrypted password):
Every row on that file includes account information for one account; the first line starts with the word
root, it has the root account information. We'll edit
this line, and only this. As you can see, the file includes several fields (information) separated by a comma
:. The second field (that is, between the second and third comma) has some "garbage-looking" letters, that's the encrypted root password. We'll remove it; let's say the line looked like this first (just an example, this is not from a real file):
Code:
root:$2$A3B4abcd$jx123EOabcwA1BcdefgHi1:12345:0:99999:7:::
after you've removed the second field's data, that line should look like this (in my example):
Code:
root::12345:0:99999:7:::
Now that you've removed that (encrypted) password, save the file and exit. Reboot your machine, and when you're asked to log in, give
root as your username (log in as root) and when prompted for a password, just press ENTER (no password). You should now be logged in...
4) Then we'll change the password to something only you know:
You are asked the new password (twice), fill it in and you're ok again.
5) Just to mention, the topic of this thread ("Urgent!!!!!!!") is bad; it doesn't tell what the problem is, and thus may not be read too quickly. In the future use more descriptive topics (like "Root password lost"), and even before that, try to search for an existing answer. I'm quite sure somebody has explained this method here already, but since you're a newcomer (only 4 posts so far), I don't mind. Hopefully you'll get the password back.
6) To make sure nobody
else does this for your root account ( heh
), make sure nobody else has physical access to your machine, root logins are forbidden over the network, only you know the root password and that your bootloader has a password only you know (that way if somebody got to your machine, it would take more time to break it). At least.
EDIT: forgot to mention, just because of these live-cds and stuff, you should also set BIOS password to prevent changing (among others) your boot settings, and set it boot from harddisk first/only. This would prevent or slow down somebody booting from a live-cd and stealing everything unencrypted (and even that) on your harddisk.