How to change permission of my CentOS if I don't have the root password?

I've setup server on Mac using VirtualBox and my server is CentOS. But the guy who did it for me forgot the root password that he setup at the beginning and what happened now is that my website has a lot of problem due to the permission issues.

So what can I do in order to retrieve the password or even to change my permission without using root?

The group for my website is apache and I believe I'm not in the same group.


Solution 1:

If you have an access to the console and you have as it is virtualbox guest you can try to:

  • Reset a password using single user mode
  • Reset a password with init=/bin/sh (where single user mode is password protected)

Reset a password using single user mode

  • Reboot a guest
  • At the GRUB splash screen at boot time, press any key to enter the GRUB interactive menu
  • Select version of the kernel that you wish to boot and type "a" to append the line.
  • Go to the end of the line and type "single" as a separate word. Press Enter to exit edit mode.
  • Boot the kernel
  • Change the password (passwd command)

Reset a password with init=/bin/sh (where single user mode is password protected)

  • Reboot a guest
  • At the GRUB splash screen at boot time, press any key to enter the GRUB interactive menu
  • Select version of the kernel that you wish to boot and type "a" to append the line.
  • Go to the end of the line and type "init=/bin/sh" as a separate word. Press Enter to exit edit mode.
  • Boot the kernel
  • Remount filesystem read-write: mount -o remount -a
  • Change the password (passwd command)