You probably don't need to uninstall or reinstall any commands, you probably just need to fix whatever's causing your PATH
variable to get corrupted.
To set it to reasonable defaults for the current shell session, type this:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Note that this only fixes it for the current shell session, and the next Terminal window you open will be back to the broken state.
To fix it for next time, you'll need to find where it's getting set wrong and fix it there.
In modern macOS, system-wide path stuff is set up in /etc/paths
and /etc/paths.d/*
(those are text-based config files). So check those first and make sure they look sane.
Also, there are system-wide shell startup scripts in /etc/
, such as /etc/profile
and /etc/bashrc
, among others. It's fairly common to set or add to your PATH
in shell startup scripts. If you, or some installer or package manager or install script has edited those, you may need to see what it did and fix it (that is, view those script files in a text editor and edit them to fix them if you find mistakes). Which ones you need to check depend on which shells you're using, how you're invoking and using them (i.e. as login, non-login interactive, or non-interactive shells), and which shell startup script files exist (some take precedence over others, so the presence of some files may cause other files not to get run). You'll need to check the man pages for the shells you're using for details on which shell startup scripts they run in which situations.
Then you need to check your own personal shell startup scripts in your own home directory. Again, which scripts get run depend on which shell you use, how you're invoking it, and which script files exist, so you need to check the man pages. You'll probably end up needing to look at ~/.profile
and ~/.bashrc
.
One last note: Assuming you copy/pasted that output text, it looks like it contains a curly quote, which suggests one of your shell startup scripts accidentally contains a curly quote. Be careful of editing shell scripts and other computer-readable text-based file formats (source code, HTML, CSS, JavaScript, JSON, XML, .plists, etc.) in GUI word processors / text editors. Make sure to turn off all the text substitution features like "smart quotes" and "smart dashes" or you'll end up accidentally getting curly quotes where you wanted a straight quote, or an em dash where you wanted two hyphens. Most computer-readable formats only consider straight quotes to be syntactically meaningful.