bash: command not found is the most common error that someone may encounter while working on a macOS (earlier know as Mac OS X) terminal or any other Unix or Linux based operating system console (or Windows command line with Bash Shell commands enabled).
Let's see some examples and what could be the cause of the issue,
- Did you get the command right?
$ grep '%looking for some text%'
Output: bash: gerp: command not found
In the above example you can see that grep is misspelled as gerp, hence the command is actually invalid! If you are unsure if it's a valid command or not look at the below comprehensive list to find one you are trying to use,
List of valid bash commands: !!, GetFileInfo, ReportCrash, afconvert, afinfo, afplay, airport, alias, alloc, apropos, asr, atsutil, awk, basename, bash, bc, bg, bind, bless, break, builtin, bzip2, caffeinate, cal, calendar, caller, cancel, case, cat, cd, chflags, chgrp, chmod, chown, chroot, cksum, clear, cmp, comm, command, complete, continue, cp, cpio, cron, crontab, csplit, csrutil, curl, cut, date, dc, dd, declare, defaults, df, diff, diff3, dig, dirname, dirs, diskutil, disown, ditto, dot_clean, drutil, dscacheutil, dscl, dseditgroup, dsenableroot, dsmemberutil, du, echo, ed, enable, env, eval, exec, execsnoop, exit, expand, expect, export, expr, fc, fdesetup, fdisk, fg, file, find, fmt, fold, for, fs_usage, fsck, ftp, function, fuser, getopt, getopts, goto, grep, groups, gzip, halt, hash, hdiutil, head, history, hostname, iconv, id, if, ifconfig, info, install, iosnoop, iostat, ipconfig, jobs, join, kextfind, kextstat, kextunload, kickstart, kill, killall, l, last, launchctl, less, let, lipo, ll, ln, local, locate, login, logname, logout, look, lp, lpr, lprm, lpstat, ls, lsbom, lsof, lsregister, man, mdfind, mdls, mdutil, mkdir, mkfifo, mkfile, mktemp, more, mount, mv, nano, nc/netcat, net, netstat, networksetup, nice, nohup, ntfs.util, nvram, onintr, open, opensnoop, openssl, osacompile, osascript, passwd, paste, pbcopy, pbpaste, pgrep, ping, pkgbuild, pkgutil, pkill, plutil, pmset, popd, pr, printenv, printf, ps, pushd, pwd, quota, rcp, read, readonly, reboot, return, rev, rm, rmdir, rpm, rsync, say, screen, screencapture, scselect, scutil, sdiff, security, sed, select, serverinfo, set, setfile, sharing, shasum, shift, shopt, shutdown, sips, sleep, softwareupdate, sort, source, spctl, split, sqlite3, srm, stat, stop, su, sudo, sum, suspend, sw_vers, sysctl, system_profiler, systemsetup, tail, tar, tccutil, tcpdump, tee, test, textutil, time, times, tmutil, top, touch, tput, tr, traceroute, trap, trimforce, tty, type, ufs.util, ulimit, umask, umount, unalias, uname, unexpand, uniq, units, unset, until, until, upsfilter, uptime, users, uucp, uudecode, uuencode, uuidgen, vi, w, wait, wall, wc, whatis, whereis, which, while, who, whoami, write, xargs, xattr, xcode-select, yes, zip
- Do you have the command available under /usr/bin folder?
$ cal bash: cal: command not found
If you are using a utility like git bash for windows you may not have all set of bash commands available.
- Is your .bash_profile set correctly?
bash: ls: command not found bash: vi: command not found bash: touch: command not found bash: mkdir: command not found bash: gerp: command not found bash: sudo: command not found bash: env: command not found
If none of your commands are working correctly, make sure you have set the file correctly, and has the correct encoding (CR/LF).
- Check your PATH variable is rightly set?
This is the most common reason why it may not work, try echoing PATH variable
$ echo $PATH /c/Users/c2c/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/c2c/bin:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files/Intel/WiFi/bin:/c/Program Files/Common Files/Intel/WirelessCommon:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Users/c2c/AppData/Local/Microsoft/WindowsApps:/c/Users/c2c/AppData/Local/Programs/Fiddler:/c/Users/c2c/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/c2c/AppData/Local/Microsoft/WindowsApps:/usr/bin/vendor_perl:/usr/bin/core_perl
Make sure usr/bin path is set correctly (the above example is from Windows - should be the same step for macOS.
You need to check if the environment variable is set correctly under System Properties ? Advance ? Environment Variables ? System variables ? Look for PATH
Comments:
- Helpful! Thank You.
anon24 24 Aug 2020 11:24:21 GMT
- I am trying to use the say command using ssh to my very old iPod Touch 2nd generation, but it is giving me - say command not found!... does that imply I do not have the package installed, if yes, how can I get it?
ask20 01 Aug 2020 12:08:28 GMT
- Further comments disabled!
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- Microsoft Office Mac Ventura: System Settings must be changed before Microsoft AutoUpdate can run - Microsoft
- How to read Huge Text Files in Notepad++ (CSV, JSON or XML) - NotepadPlusPlus
- What does chmod +x filename command do? - Linux
- -bash: startup.sh: command not found - Apache Tomcat 8 - Tomcat
- How to know if someone has read your WhatsApp message - WhatsApp
- Python: Convert int to binary String - Python
- How to Turn off "Terminal" would like to access files message on Mac? - MacOS
- How to reset Eclipse IDE Code Font - Eclipse