5

I took the RHCSA test a couple of weeks ago, which is a lab/hands-on test. The first step is to gain root access of the VM. Usually (and this works okay on my PC's VirtualBox CentOS 7 VM) I do this by adding kernel parameter init=/bin/bash rw. But on the test's VM this did not really work. After the kernel dropped me to root password, the text that I typed did not echo to the terminal even after I issued reset. Changing password using passwd proved to be impossible because the terminal seems to eat some of my keystrokes. I had to resort to using kernel parameter rd.break. The question is why, especially the weird terminal behavior?

1
  • I think it is related to the initrd, it is loading something that is broken the terminal.... Not intentional.... – Luciano Andress Martini Aug 1 '17 at 14:51
1

This may not be the answer that you are looking for, but just to mention that, you can erase the password from your /etc/shadow file once you have added your init=/bin/sh(I prefer sh because is likely to be on every *nix environment because of historical reasons, it could even be a symlink to bash, but you get the point.

once in your shell, always remount your drive with mount -n -o remount,rw / and go to your /etc/shadow file. You should read something like:

root:123l4kj'0978dsfgasfli132094187234aposdiuf987:14414:0:99999:7:::
.....

erase all the encrypted string and leave it like:

root::14414:0:99999:7::

After that you can reset your VM and the next time you boot you log with root and no password

PS. here is a tutorial about this

1
  • Well, the problem is the terminal's input got screwed up and ate many keystrokes. If I couldn't successfully type "passwd" then enter the new password twice successfully (the terminal seemed to eat the first character of every line, and some characters in between, seemingly randomly, and I couldn't turn on echo), what hope I have typing more complex stuffs? :) I guess I can use sed or perl to erase the field in a one-liner... But anyway, the question is not about how to actually change the root password, but why using "init=/bin/bash" makes the terminal screwy on RHEL 7.3? – Gerry Lufwansa Aug 16 '17 at 12:04
0
init=/bin/bash rw

But this "rw", what is it doing there? Will it not be interpreted as argument to bash? First root gets mounted, then /bin/bash can be started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.