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!
- How to Display Analog Clock on Mac Menu Bar
- Shutdown Mac Terminal Command
- How to know the Serial Number of MacBook on macOS Ventura 13.0
- macOS: Remove Desktop or Documents Folder from iCloud Drive Syncing
- [fix] How to Show file extensions on all files on Mac
- How to install Zoom Add-in to Outlook (Mac)
- How to turn off Stage Manager - macOS Ventura
- Fix - Xode - Internal logic error: Connection was invalidated
- How to do calculations in Mac Terminal
- How to delete a Page in Microsoft Word File on Mac (macOS)
- How to Refresh Mac Desktop
- How to install Java on macOS [Big Sur]
- How to Disable Mac Terminal Bell Sound
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to Uninstall Brew on Mac
- Find your macOS version
- Change TextEdit File Encoding
- AppleScript Example with TextEdit
- How to install homebrew (brew) on M1 Mac
- How to Find File and Directory Size in Mac Terminal
- How to open new tab in Sublime Text Editor [macOS]
- How to list all users in Mac Terminal
- Turn off Auto-Capitalization on macOS Ventura 13
- How to check Command Line Tools Version [Updated for Ventura]
- Change Current User Password using Mac Terminal Command
- Change CKEditor Table Properties default width - CKEditor
- Iterate over an Array using Java 8 Stream and foreach - Java
- How to take a screenshot of android emulator (AVD) screen - Android
- Python: Replace the First Occurrence of String in a String - Python
- How to Change Mac Computer and Localhost Name using Terminal - MacOS
- How to Save Jupyter Notebook as PDF - Python
- How to Turn off "Terminal" would like to access files message on Mac? - MacOS
- Capitalize the first letter of each word using Notepad++ - NotepadPlusPlus