I'm really new to Mac OSX and UNIX based systems. I wanted to run a few Windows games on my Mac Mini so I started installing Wine and MacPorts.

I think the installs are correct, but when I type sudo port install wine I see a not found error in my terminal. I tried other basic commands like say and clear and all of them return the same not found error.

My research shows that my PATH might be incorrectly set, but it lacks steps I can implement.

Specifically, I ran this command: echo $PATH and it returned:


I'm a complete newbie to mac and have no idea where .bash_profile or any of those files are. My skills let me install Xcode and the Command Line tools for Xcode and I sense I need to level up on path management.

At this point I need help managing my dot files and changing my path to fix these specific errors on Mountain Lion.

What are my next steps?


9 Answers 9


$PATH should contain these folders: /usr/bin:/usr/sbin:/bin:/sbin.

Try editing ~/.bash_profile, ~/.profile, or ~/.bash_login (with for example /usr/bin/open ~/.bash_profile -a TextEdit) and commenting out any lines that modify the path.

If that works, you can add a line like export PATH=/opt/local/bin:/opt/local/sbin:$PATH to ~/.bash_profile.

  • 1
    Note: starting in macOS Catalina (10.15), the default shell is zsh instead of bash, so look in ~/.zprofile (or maybe ~/.zshenv or ~/.zshrc) instead of the bash files. Commented Sep 19, 2021 at 22:46

Similar problem was happening to me, so what I did was:

1) typing export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" into the terminal in order to make it temporarily working

2) Editing bash_profile by typing /usr/bin/open ~/.bash_profile -a TextEdit

3) When I opened my bash_profile file I realised the last line export looked really messy with some strange symbols, so I changed it entirely to export PATH=/opt/local/bin:/opt/local/sbin:$PATH

I'm an absolutely beginner at this but I managed to get those steps by reading pieces of solutions from different questions on SE, so hope it could help someone else.

  • 1
    This is the best answer to this issue, well done and thank you for sharing it. I came across the same issue and only when I read yours I was able to fix it.
    – panza
    Commented Oct 23, 2020 at 16:06

It sounds like you overwrote your path rather then just adding to it.

Make sure when you set your PATH you include "${PATH}" to include your existing path, as well.

By default the $PATH is set in a couple of files. Technically you should add to your $PATH in the .bash_profile file in your home directory.

One suggestion if to check if a certain folder exists before you add them to your PATH.

For example I have:

if [ -d /usr/local/bin ] ; then

if [ -d /usr/local/mysql/bin ] ; then

if [ -d /opt/local/bin ] ; then

if [ -d /opt/local/sbin ] ; then

if [ -d ~/bin ] ; then

(The -d directory command checks to see if the directory exists)


For me I got into this exact issue when I attempted to add a new directory to PATH using an incorrect export command in my ~/.bash_profile. Both examples below.

export PATH=/some/new/path:PATH (incorrect, note missing $)


export PATH=/some/new/path:$PATH (correct)

In addition to the fix it answers, I'd also like to call out one thing to test.

If your current window simply has a bad PATH variable and your system isn't more broken, you can fix the path easily:

echo $PATH

Compare the output of the two above commands. If you want to return to a "safe" path, just copy and paste the line that the path_helper provides into that terminal. On an unmodified Mac 10.11 system, you should have this output from the helper tool:

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

If your path needs to be customized, then look to the excellent answers also on this question.

  • 1
    Or you could issue PATH=$(/usr/bin/getconf PATH) to get a usable PATH in the current shell. /usr/local does not exist on an unmodified system.
    – fd0
    Commented Oct 1, 2015 at 17:05
  • Excellent @fdo - I'm not aware of what might mess up getconf so that might be just as good as just hard coding things. It's also shorter than my "brute force" fix.
    – bmike
    Commented Oct 19, 2015 at 15:42
  • 2
    path_helper constructs the PATH from the current PATH, the /etc/paths file, and any files within /etc/paths.d. It can also be influenced by any PATH settings in /etc/launchd.conf. getconf prints the system PATH hard coded in the kernel- sysctl user.cs_path.
    – fd0
    Commented Oct 20, 2015 at 15:48

Your terminal's ./bash_profile may have been overwritten.

Use export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin in the terminal to temporarily rewrite the current PATH settings. This should give you access to sudo and nano which you will then use nano .bash_profile. For me, deleting everything in the file worked.


Check to see if the folder-address is present in PATH variable. Type on the terminal:

echo $PATH

Terminal will display: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ...(other paths in concatenation)

My prime motivation to share this answer is, you must first check if PATH variable includes the folder-address, which you are looking for, as one of its values. Moreover, the PATH fetches its values from multiple locations such as /etc/path, ~/.bash_profile, /etc/path.d, ~/.zshrc If you can't find yours, then it's evident that folder-address must be included in PATH. If it isn't, PATH won't be able to recognize your command. You can achieve this in these 2 ways:

(Method 'B' worked like a charm for me)

A. (May work) Write it inside .bash_profile file in ~ i.e. Home folder (like many previous answers have mentioned above.)

B. (100% works) Write it inside the /etc/paths file. (paths file is found inside /etc folder. Firstly, make sure you have read+write access in order to edit this file. Secondly, system settings won't allow editing because editing creates a duplicate copy of this file which will be irrelevant. Hence, better edit with it vim). Simply insert the folder-address at a new line in this file.

Relaunch your terminal and fire up the command you wanna check for.

  • Thanks! @nohillside for the correction. Commented Mar 14, 2021 at 16:07

Worth checking your Terminal preferences. From the keyboard, press the Command and comma keys [⌘ ,]. Then click on "Profiles" and select the "Shell" tab. Make sure the startup run command has the correct command. (Defaults to empty text.) Try unchecking the run command option and open another terminal tab. It should default to your system's default shell.

Default setting for Terminal shell profile

Somehow during the upgrade process between Mojave and BigSur, my preference in the shell run command was changed to "-bash"... This was causing the

-bash: -bash: command not found

error in my case as there were zero problems with my .profile , .bashrc, and .bash_profile files.


None of the solutions worked for me So I manually removed the files in the root folder path. Then worked. The path I found was /Users/...**. It was hidden files so made it visible and removed the bash_profile and zprofile. Then mac terminal was working fine.

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 19, 2021 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .