0

I'm a noob. I'm messing around on a raspberry pi trying to get the hang of things. I'm having a jolly time.

I don't now how to use vim. I know that you need to hit i to insert text, but I know very little about the commands to get things done.

Raspberry pis start you with a user named pi. There is also the root user. I was trying to update the password for the root user so that I could log into it instead of pi.

Because I don't know how to use vim I accidentally overwrote one of the colons separating data for the root user with an 8 or something. I was all like, I need to get out of here! :wq "Wait... No! That must mean write and quit!"

Is there any way that I can fix this. I will just reinstall the OS otherwise.

I'm nearly certain using root like this is a terrible idea, but whatever. I wouldn't do this for anything important. I'm literally just farting around and learning lessons. I was going to see if it allowed me to add another user, because I keep getting a limit message with 'pi'.

1
  • 1
    Also use the 'passwd' command to set passwords. Type 'man passwd' for info. The password entry in /etc/password is not in plain text, so you can't edit that field manually.
    – Tyson
    Aug 17, 2015 at 17:23

1 Answer 1

0

You have Linux on your Desktop PC?

Before you stared using your Rasperry Pi you wrote a image (like raspbian) on your sdcard. In this image there is also the /etc/passwd file.

So first of all you have to extract the original passwd file from the image you have downloaded:

sudo kpartx -av raspbian.raw # setup loopback and mapper block devices
sudo mount /dev/mapper/loop0p1 /mnt # mount partition to /mnt
sudo cp /mnt/etc/passwd ~/passwd # copy passwd to home

Then mount your sdcard with terminal or with your graphical user interface. After that you can copy the original passwd file to the sdcard:

sudo cp ~/passwd /media/username/mmc/etc/passwd # copy passwd to sdcard
sync # flush buffers

Now you can insert the sdcard back into the raspberry pi and try again.

Please note that kpartx is a special tool, which is not default installed on Ubuntu, you have to install it with

apt-get install kpartx
1
  • Thanks! I ended up just reinstalling the OS. I am using NOOBS, so the boot process seems a bit different than normal (maybe I'm wrong). It only takes 5 min to reinstall, so maybe I'll break it again and try what you're saying. Aug 17, 2015 at 22:02

Not the answer you're looking for? Browse other questions tagged .