accidentally commented root user at /etc/passwd
Hello everyone,
I need help on this asap. I accidentally commented the root user at /etc/passwd. #root:x:0:0:root:/root:/bin/bash thus, I cannot su - using SSH. It gives me the error: su: user root does not exist Can anybody help me on this? Thanks in advace. Karen |
Your going to want to boot your machine on a live cd like knoppix, mount the drive, and uncomment out the root user. Then reboot without the CD and you should be just fine.... If you need any more in depth instructions let me know.
|
Thanks so much for that very quick reply.
Im a total Linux newbie, and yes I need a more detailed procedure. 1. Where can I download knoppix? 2. When you say mount the drive, how will I do that? Cheers! |
You can get Knoppix here.
I believe it will automatically mount your HD's in the /mnt or /media directory when it boots... but if not let me know and I'll attempt to walk you through it... |
Thanks for the download link.
If I do the mount, will if affect any settings or files in the server? Will I not lose any information? When I do df-h, here is what I get. Filesystem Size Used Avail Use% Mounted on /dev/hda1 4.9G 206M 4.4G 5% / none 121M 0 121M 0% /dev/shm /dev/hda6 7.9G 786M 6.8G 11% /home /dev/hda3 9.7G 1.5G 7.8G 16% /usr /dev/hda2 9.7G 5.3G 4.0G 58% /var |
You don't need a live cd. Just:
Append 'init=/bin/sh' to the boot command line. remount / rw (mount -o remount,rw /) edit /etc/passwd remount ro (mount -o remount,ro /) exec /sbin/init to continue booting normally (you don't need to reboot). |
Quote:
You can probably also append 'single' to the kernel parameters on bootup and get in that way. |
Quote:
If you were to do have to do the mount yourself through knoppix open up a terminal and do the following mkdir /mnt/hda1 sudo mount /dev/hda1 /mnt/hda1 edit /mnt/hda1/etc/passwd reboot |
Originally Posted by dawkcid
You don't need a live cd. Just: Append 'init=/bin/sh' to the boot command line. remount / rw (mount -o remount,rw /) edit /etc/passwd remount ro (mount -o remount,ro /) exec /sbin/init to continue booting normally (you don't need to reboot). Hi dawkcid, Im using SSH. When I typed, init-/bin/sh, in the "Login as" prompt, it asked for a password. I typed the password for root, but did not accept it. login as: init=/bin/sh init=/bin/sh@202.91.163.28's password: Access denied Any ideas? Or I should type directly to the actual server's prompt and not thru SSH? Thank for your help. :) |
Do you have physical access to the computer?
The init=/bin/bash is a kernel boot option and not an ssh login name. |
Yes, I also have physical access to the server.
Can you walk me through the process? Sorry, Im a total linux newbie and not so familiar with that kernel boot thing.:scratch: |
Enter init=/bin/bash in the boot menu's kernel options.
Then run an editor such as vim and edit out the comment character. You can also use sed to delete the "#" character on the line containing root: sed -i '/root/s/#root/root/' /etc/passwd |
when i typed: init=/bin/sh to the boot command line, It says :
the kernel parameter does not exist. Even when I use/type 'single', it gives the same kernel error. Any ideas? |
oh sorry about that, the error said:
Could not find kernel image: init=/bin/sh or if i type 'single' Could not find kernel image: single Any ideas? |
Add "init=/bin/bash" to the end of what is there. If that doesn't work or there isn't anything on the line try "linux init=/bin/bash".
The single option might work, but I think you may need the a root password, which won't work in your case. Another option is to boot up with a rescue disk, mount the root partition and edit out the "#" character you added. Then save the file and reboot. |
All times are GMT -5. The time now is 08:52 AM. |