CentOS lost Root Access

centosrootsudounix

For some reason I cannot access my root user via SSH. It displays the error on login:

could not open session.

However I happen to have another user account that is a normal non-sudo user. Is there any way I can run a su root command or anything to make this user with sudo privilege?

I have the password of the root user.

Best Answer

If you messed up your limits such that they prevent you from logging in, you'll need to reboot the machine into maintenance mode. Depending on exactly what sort of problem you created, adding single to your boot options (in grub, hit "e" to edit the kernel line, add single to the end, hit esc to exit, then press "b" to boot) will often be enough to give you a shell. If you messed things up in a slightly different way, try adding init=/bin/bash to the end, instead. In either event, that should give you enough access to resolve the issue.

If none of that works or in the worst case, you can always fire up a LiveCD and mount the affected drive in order to undo the changes you made.