Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Running

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 stackoverflow.com 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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.