Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to add a path so that the system could find some manually installed executable. However, instead of typing PATH=xxx:$PATH;export PATH at the end of ~/.profile where xxx is the directory in which the executable lies, I wrongly used PATH=xxx;export PATH.

After I logged out I was unable to log in the usual way. How can I fix this instead of reinstalling?

share|improve this question
Boot from a live cd and delete the path ? – karthick87 Jan 2 '11 at 7:40
But how to get into my ~/.profile to change it from the live cd? Please elaborate. – user7182 Jan 2 '11 at 7:45
Boot from a live cd,open nautilus browser and then open your filesystem(not live session file system).Search for home directory and then user directory.Press CTRL+H to view hidden files and then edit your ~/.profile – karthick87 Jan 2 '11 at 7:55
You can combine / shorten the line to export PATH=xxx:$PATH. – Lekensteyn Apr 16 '11 at 8:57
@lekensteyn What is the syntax if I want to add two paths using (a) my method and also (b) your method, other than repeating a new line? – user7182 Apr 16 '11 at 11:13
up vote 3 down vote accepted

In addition to @João Pinto's answer, you cannot use text editors like gedit or Kate. For the terminal or console, use text-based editors like nano.

The full steps needed to make changes to the ~/.profile file:

  1. Press Ctrl + Alt + F1 to switch to a text console
  2. Login with your username or password
  3. Restore your $PATH variable by restoring the environment so you can run nano without specifying the full path:

    . /etc/environment
  4. Edit the ~/.profile file by running:

    nano ~/.profile

    Use Arrow keys, Page up or Page down to move the cursor. As with text editors like Kate, you can use Backspace or Delete to delete text before or after the cursor and insert text by typing it.

  5. After making the changes, save the changes and quit the nano editor by pressing Ctrl + X, followed by Y to answer yes on saving changes. Finally, press Enter to confirm the filename.
  6. You can now logout from the console by pressing Ctrl + D (or by executing exit)
  7. Switch back to the graphical login by pressing Ctrl + Alt + F7 or Ctrl + Alt + F8 if F7 did not work.

If this does not work out-of-the-box for whatever reason, then we can always revert to karthick87's answer which Jasper added as an answer below: using a LiveCD to make changes.

share|improve this answer

Changing the profile with PATH=xxx;export PATH will not prevent you from loggin in, at least not from the console. Switch to the text console with: CTL-ALT-F1, login, edit the file with your prefered text editor.

share|improve this answer
Note to other users: Although I could log in from the console, I could not fire up any editor to edit the file, so it might be best to boot from the live cd, edit the file and then log in as usual. – user7182 Mar 26 '11 at 13:27
@jasper: that's because your $PATH variable got messed up. Instead of running nano ~/.profile, you should run /usr/bin/nano ~/.profile. Alternatively, you can load the default environment with . /etc/environment and run nano ~/.profile after. – Lekensteyn Apr 16 '11 at 8:56
@lekensteyn Is it right to say this works only if you have an editor capable of running from the console already installed? Also please add your comment as an answer, thanks! – user7182 Apr 16 '11 at 11:15
@Jasper: I've added a complete answer. Novices should understand it. If not, you're welcome to fix the errors or missing information. – Lekensteyn Apr 16 '11 at 12:16

(This is essentially karthick87's answer but I could not get him to add his comment as an answer, so I am putting this answer down for other users.)

Boot from a live CD and open your filesystem from Nautilus (not file system of live session). Search for the home directory, use CTRL+H to view hidden files and then edit ~/.profile. After that remove the live CD and log in as usual.

share|improve this answer

Your Answer


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