Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 tried to login, I cannot, so I have tried booting in recovery mode, entered root prompt and tried to edit 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. Please help me out guys..

share|improve this question
    
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 '12 at 13:34
    
can you logout and login as a guest? And then in the terminal as root change your profile? –  Julien Chau Jun 9 '12 at 14:22
    
@pl1nk, I had added :$PATH also to that line. –  kunaguvarun Jun 9 '12 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.. –  kunaguvarun Jun 9 '12 at 14:59

4 Answers 4

up vote 4 down vote accepted

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!

share|improve this answer
    
Worked bro.. Really great help :) –  kunaguvarun Jun 9 '12 at 17:13

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.

share|improve this answer
    
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? –  kunaguvarun Jun 9 '12 at 16:41
    
Oops, didn't think of that. I added this to my answer for better formatting. Hopefully, this will help you. –  Marty Fried Jun 9 '12 at 18:15
    
Thanks for the help... –  kunaguvarun Jun 10 '12 at 3:24

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.