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:
- Press Ctrl + Alt + F1 to switch to a text console
- Login with your username or password
Restore your $PATH variable by restoring the environment so you can run nano without specifying the full path:
. /etc/environment
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.
- 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.
- You can now logout from the console by pressing Ctrl + D (or by executing
exit)
- 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.
export PATH=xxx:$PATH. – Lekensteyn Apr 16 '11 at 8:57