9

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.

4
  • I guess you wanted to add the /opt/myjdk7 to your path revert to your old (un-edited version) .profile and enter at the end of the line export PATH = /opt/myjdk7 Check this for more help.
    – pl1nk
    Jun 9, 2012 at 13:34
  • can you logout and login as a guest? And then in the terminal as root change your profile? Jun 9, 2012 at 14:22
  • @pl1nk, I had added :$PATH also to that line. Jun 9, 2012 at 14:58
  • @JulienChau, No I cannot even login as guest... I've even tried using the recovery mode root prompt, but vi opens the file as read only.. Jun 9, 2012 at 14:59

6 Answers 6

12

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!

1
  • 1
    Worked bro.. Really great help :) Jun 9, 2012 at 17:13
7

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.

0
3

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.

2
  • Thanks for the help.. I've installed Ubuntu right now using the wubi option. So, how could I edit the file from /etc directory now? Jun 9, 2012 at 16:41
  • Oops, didn't think of that. I added this to my answer for better formatting. Hopefully, this will help you. Jun 9, 2012 at 18:15
1

I was stuck in a same situation and in my case sudo was not available in my PATH (when I tried in shell). This one worked out for me

/usr/bin/sudoedit /home/yk/.profile

I changed the .profile file and logged in with no problem.

0

You could avoid all the rebooting & trickery if you just had a way to make the filesystem read-write in recovery mode. The following works for me:

mount -o rw,remount /

Now root can read and write, and you can do whatever you need to fix /etc/profile.

0

I had the same problem today, here is what I did: when you get to the login screen: CTRL+ALT+F1, login to tty1; now because the PATH is bad, most commands like ls, nano, grep etc wont work. However, you can still read the .profile file with less .profile (not more) and delete it with unlink .profile (maybe .profile~ too). The you can login again.

Hope that helps someone.

You must log in to answer this question.

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