Typing ‘ls’ ‘cd’ ‘bash’ and it returned “command not found” on Mac OS X? If yes then you are in the right place.

I have also experienced this, at first I was disturbed, thinking I did mess with my terminal configurations, but it was just a misconfigured path settings.

So from the wrong path I set via ./bash_profile couldn’t read the ./bash_profile or .bashrc, well what causes mine was my desperation to install Hugo CLI, so I did everything to get it installed.

Within me, I did know I have messed up with my Terminal, so I quitted the terminal while I wasn’t using it, and when I needed it back the command not found starts its show.

Like every other tech and non-tech geek, we google search, yeah I did that, but the solution of deleting the Terminal configuration in /Library/Preference and restarting the system.

So I moved on to find another solution, and here is what worked for me.

How I Fixed “Command Not Found” Terminal Error in Mac OS with $PATH Setting

ls, bash, cd, no command was working but echo $PATH was there for me, so when I echoed the path,  I see a long list, my path was configured via the Hugo folder, lol, so I entered the following command.

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

And yes it worked, I typed ls, cd and everything works, but I still had feelings that something isn’t right here, so I decided to close my terminal and reopen it, and I typed ls, cd and the Command not found was back again.

So I calmed my nerves down and entered the above command again, I was able to type ls, cd, nano. Then I used that chance to clear the mess I made in my ./bash_profile, all I did was nano ./bash_profile, you can also use vim to edit it anyway

So the line contains the setting of echo $PATH… blah blah, that was giving me the headache, I removed it completely, and saved it, then I typed source ./bash_profile to read and execute the new changes made in the file.

That was how I got freed from the Command not found ish, also this solution works for all UNIX and Linux terminal, so it’s not meant for Mac OS X alone.

But what if this solution doesn’t work for you? That brings us to more solution suggest

“Command not found” because a system directory is missing?

Well this happens most of the time, cleaning up files either through finder to through terminal using rm/rf and you know rm/rf is a fast trash cleaner, It won’t save those trash in the trash CAN for you instead it deletes it completely unlike finder, that still keeps them for you in the trash can.

Here is how you can restore deleted or missing system files to Mac OS or Mac OS X, it usually involves restoring from backup or reinstalling the system software itself.

“Command not found” because command isn’t installed? Use HomeBrew

That `-bash: brew: command not found` error, lol, am not a big fan of brew or Home-brew, so I always find another solution to get things installed on my terminal, but for the brew fans here’s how to fix this error

Run the following command on your terminal

“/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

run the command without the

if this doesn’t work, then this will definitely work

sudo chown -R $USER:admin /usr/local/*

“Command not found” because of human repeated error

Yeah, this happens most of the time, I did remember mistaken imagick for imagik, I got the command not found and I didn’t look or think twice I re-entered the command to install imagick, it was on my clipboard, so I wasn’t typing it, made it easier for it to eat up another second of my time.

So next time you have any error popped up on your system or anything you do, calm down, look into the error closely and diagnose it with care, it might just be that rewriting the command in another way will fix issues.

Also if you ever countered the issue of command not found, but your issues and fix weren’t similar to any of the thing we talked about here, please feel free to share them via the comment, someone else might have the same issues too.

4 COMMENTS

  1. An impressive share! I’ve just forwarded this onto
    a coworker who had been conducting a little research on this.

    And he actually bought me lunch due to the fact that I discovered it for him…
    lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to talk about this subject here on your
    blog.

  2. An impressive share! I’ve just forwarded this onto
    a coworker who had been conducting a little research on this.

    And he actually bought me lunch due to the fact that I discovered it for him…
    lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to talk about this subject here on your
    blog.

LEAVE A REPLY

Please enter your comment!
Please enter your name here