Q:

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.

A:

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.
PATH=/opt/jre1.7.0_04/:$PATH

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

A:

I know this thread might be old but I had the very same problem, my PC not show grub loader nor had I have a copy of Ubuntu nearby, so on the login screen press Ctrl+Alt+F1, log in and use nano as root to remove the changes made:
sudo -s
nano /etc/profile

Then Ctrl+Alt+F7 to switch back to GUI login screen. That's it.

A:

First of all, a little late, but you should not be editing the profile in /etc (or anything else in that directory if you're not sure of what you're doing).  You should make changes like that in your home directory, to the file ".profile".  Then, if you mess up, it's easier to fix, and if you ever have more than one user, it won't affect all users.
Next, thing is that you need to be careful with spaces for any linux command.  Spaces are what separates parts of the command, so if you actually have a space in your path or filename, you need to either use double-quotes, or a backslash in front of the space, like this: file\ name\ with\ spaces.  This is called "escaping the space".
To fix your problem, you will probably need to boot from a live CD, either the original or a repair disk.  Once booted, you can find your installation on the hard drive, change to the /etc directory, and edit the file, preferably by removing your changes and making them correctly in your home directory.
Edit:  Fixing the problem when using wubi
I've never used wubi myself, but there are ways to access the partition either from Windows, or from a live CD or linux utility CD.  There are details in the Ubuntu WubiGuide, but here is the basic from that guide (untested by me):
Boot the Ubuntu Desktop CD, or another LiveCD, then mount the windows partition:
sudo mkdir /win
sudo mount /dev/sda1 /win

Replace sda1 with the appropriate device (a = disk, 1 = partition number), then mount the virtual disk therein
sudo mkdir /vdisk
sudo mount -o loop /win/ubuntu/disks/root.disk /vdisk

Now the content of the virtual disk will be visible under /vdisk. 7.04 users will have to install ntfs-3g first and specify it as fstype to gain r/w access. 

