I have lost or forgotten the root password. is there a way to recover it or reset it?
There are two ways. If you account is in the sudoers list, you can use this command:
sudo passwd root
Otherwise, boot into Recovery Mode
- Restart the Mac.
- Right after you hear the chime, press and hold the Command and the R keys for a few seconds, then release. Soon, you'll see the Apple logo and spinning gear. This will force the Mac to boot into OS X on the recovery partition that was created when you installed OS X 10.7 or later.
- When booting is complete, you'll see a window of "OS X Utilities." You won't do anything there. Instead, you'll go to the Menu bar at the top and select Utilities > Terminal.
In the terminal window, type the following and press the Return key.
A new window will open and click on the volume of interest and select the desired user account in the popup. Then enter the new password twice. A password hint is optional. Click "Save."
- Go back to the Apple Menu at the top. Select OS X Utilities > Quit OS X Utilities. That will prompt you to restart the Mac.
You can find the guide here to reset the root password here.