Super User is a question and answer site for computer enthusiasts and power users. 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

Having an issues with my terminal. Every time I tap in a command such as ls i get

Patricks-MacBook-Pro:~ patrickwalsh$ ls
-bash: ls: command not found


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

fixes it but only temporarily. If I close the window and reopen for example then I am back to the above problem.

Any help or advice would be great.

share|improve this question

migrated from Jun 10 '13 at 0:08

This question came from our site for professional and enthusiast programmers.

When the problem occurs, what does echo $PATH give you? – mfaerevaag Jun 9 '13 at 18:17
It returns the following Patricks-MacBook-Pro:~ patrickwalsh$ echo $PATH /usr/local/bin – PatGW Jun 9 '13 at 18:22

Add this to you ~/.profile or ~/.bash_rc:

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

and remove any other PATH-declarations (like the one above).

share|improve this answer

When making a PATH declaration in your ~/.profile, make sure you append ":$PATH" so the contents in the original PATH variable do not get lost.

For example, if your .profile has:

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

export PATH=/usr/local/bin/python

The shell will have lost reference to the "stock" commands due to the second declaration. Instead, a simple change to the second EXPORT line

export PATH=/usr/local/bin/python:$PATH

should fix the problem!

share|improve this answer

You must log in to answer this question.