7

I typed something in Bashrc and I can not use commands like cp, gedit, ls, etc. etc anymore. The terminal give me a message like:

Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found

I tried to restore bashrc, but I need to use cp and I can not use this command either:

Command 'cp' is available in '/bin/cp'
The command could not be located because '/bin' is not included in the PATH environment variable.
cp: command not found

What could I do? Thank you.

muru
  • 197,895
  • 55
  • 485
  • 740
ogs
  • 71
  • 1
  • 1
  • 2

1 Answers1

30

It looks like your PATH variable got messed up.

If this ever happens to you, and you are running a /bin/sh (or variant such as /bin/bash)....enter the following on the command line:

 export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin

Then you will be able to easily use the base UNIX commands without having to prefix them with /....blah..../command while you are fixing the problem.

Jeremy Kerr
  • 27,199
mdpc
  • 1,199
  • 1
    I've run this command and without rebooting the path variables got lost again without editing the bashrc again. Am I doomed into having to constantly update path in .bashrc whenever installing new software? – janat08 Jan 20 '19 at 00:59
  • @janat08 it might be something in your bashrc that is causing the issue. I removed a export PATH line I had and it fixed the issue (I had added that line earlier). – Riza Khan Oct 27 '20 at 23:43