2

I was trying to add something to the PATH with :

export PATH=/user/home/sbt/bin

but I removed all of the content of PATH and I can not run any command on the terminal even ls ! So what should I do ? Can I fix it ?

5
  • Have you tried with sudo PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games? This will only work for the actual session.
    – Lucio
    Mar 25, 2013 at 18:54
  • Thank you @Lucio it helped me, but is there any way to undo to the old content ?
    – myildirim
    Mar 25, 2013 at 18:56
  • Did the method of the answer below worked for you?
    – Lucio
    Mar 25, 2013 at 19:09
  • Also, to know what paths do you have, enter cat /etc/environment in a terminal.
    – Lucio
    Mar 25, 2013 at 20:29
  • @Lucio, after log out and log in the below worked for me
    – myildirim
    Mar 25, 2013 at 22:45

3 Answers 3

3

Close the terminal app, and open a new one. The variable will be reset to its original state then.

If you're on a virtual terminal, and not running gnome-terminal or similar under X11, then you can log out and log back in again, to reset the variables. You can type exit to log out, or press Ctrl+D.

0

In case, the answer by dobey doesn't work for you.

Follow these steps to recover the PATH environment variable :

  • Delete the culprit file from /etc/profile.d/ (if any)
  • Delete the culprit line from /etc/profile or ~/.bashrc (if any)
  • Execute source /etc/environment to start reseting the path environment variable
  • Execute source /etc/profile followed by source /etc/profile.d/*
  • At last source ~/.bashrc
0

For you case you could Use command: export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/user/home/sbt/bin

then use command sudo gedit /etc/environment delete whatever it is in then copy and paste this PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/user/home/sbt/bin"

finally run a command source /etc/environment

Now you should be fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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