Ubuntu – Ubuntu stuck in a login loop after editing profile file


I'm stuck in a login loop now. What I did was edited /etc/profile as root and added the following line:

export PATH = /opt/my jdk 7 path/bin:$PATH

After logging out and trying to login, I cannot, so I have tried booting in recovery mode, entering the root shell editing the file in vi but it always opens in read only mode and hence cannot be saved.

I just need a way to delete that line and boot into Ubuntu again.

Best Answer

Select recovery mode at the GRUB bootloader, and then it will give you a menu.

Select the dpkg menu item.

Say "Yes" when it asks you if you want to continue.

It will fix some stuff (or at least, try to). This might take a while, you can safely ignore most of the 'errors' there.

It will say

Finished, press enter

press enter, and then it will be in read/write mode so you can then select root prompt, and edit your stuff, and then reboot.

Now, to add it to your $PATH, add the following to your ~/.profile.


and then log out, log back in and you should be good to go!

Related Question