Thursday, September 4, 2008

Getting access to your linux box without password

For BSD:
In order to recover your root password, you must boot FreeBSD in single user mode, mount the filesystems read/write and issue the passwd command. The passwd command will not actually recover your root password, but will allow you to change it to something new.

Boot in single user mode
As the operating system is starting, it will display the following message:Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel] in 10 seconds...
You should now press the space bar, and you will see the following message:
Type '?' for a list of commands, or 'help' for more detailed help.ok>
Now type boot -s and press the enter key to start FreeBSD in single user mode.
ok> boot -s
After the system boots, you should see the statement:
Enter full pathname of shell or RETURN for /bin/sh:
Press the enter key and you will have a # prompt and you can change the password using passwod command

For RH Linux
Booting Single-User Mode
You may be able to boot single-user mode directly. If your system boots, but does not allow you to log in when it has completed booting, try single-user mode.
If you are using GRUB, use the following steps to boot into single-user mode:
If you have a GRUB password configured, type p and enter the password.
Select Red Hat Linux with the version of the kernel that you wish to boot and type e for edit. You will be presented with a list of items in the configuration file for the title you just selected.
Select the line that starts with kernel and type e to edit the line.
Go to the end of the line and type single as a separate word (press the [Spacebar] and then type single). Press [Enter] to exit edit mode.
Back at the GRUB screen, type b to boot into single user mode.
After boot, you can change the password of root using passwd command

No comments: