Whenever I start a new terminal and try to run a command, I get this error. I have found out that it can be solved with export PATH=/usr/bin:/bin, but it has to be done for each terminal I open. In the etc/environment file, the path is correct, so hence I do not understand what is wrong.(But this error appeared after I added some lines to bashrc and paths to have some shortcuts for ruby, rails , git ; ( was following a course on Coursera )). How can this be fixed?

7

1 Answer

What's happened here is you've clobbered your PATH variable. Your PATH is pretty important, whenever you enter a command your shell (usually bash), will check each of the directories specified in your PATH for a program of the same name.

Each directory specified in your path is separated by a colon :, and a minimal PATH variable usually looks something like /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.

When you have the line export PATH=/usr/bin/git at the end of your .bashrc you are telling your shell that you only want to search /usr/bin/git for commands.

Instead, the line export PATH="$PATH:/usr/bin/git" will tell your shell to search all of the directories previously specified in your shell, and then search /usr/bin/git.

Another thing to note is that your shell will search the directories in your PATH in the order they're specified, and use the first matching command found, so the order that directories are specified in the PATH can matter too.

2