Linux
Dedicated subjects
Add a user account
Add a system user
useradd -r username
Restore root password
RHEL/CentOS
Reboot the server, and press e to edit the GRUB command line.
Add rd.break at the end of the linux16 line and press ctrl-x to boot in single user mode.
Mount the filesystem in rw:
mount -o remount,rw /sysroot
Chroot inside the folder:
chroot /sysroot
Then change the root password:
passwd root
If SELinux is installed and running, don't forget to relabel the FS:
touch /.autorelabel
Type exit twice and you are done.