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!
- Opening mac Terminal
- How to change default macOS Terminal Window size
- How to clear Mac Terminal screen
- Find Hostname of Mac running on macOS Ventura 13
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to switch from bash to zsh shell in macOS Terminal
- Limit scrollback rows in macOS Terminal
- How to Set Background Wallpaper on macOS 13 Ventura
- This operation couldnt be completed. Unable to locate a Java Runtime. [macOS]
- Encode or Decode Base64 String using Mac Terminal Command
- List of All Apple Silicon ARM Based M1/M2 Mac [updated Oct 2022)
- How to remove Siri from Menu Bar [macOS Big Sur]
- Must Know Homebrew Commands for Mac/Linux Users
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- 13.0 MacOS Ventura release date
- How to change the default location of Mac Screenshot
- How to set Out Of Office (OOO) on Outlook for Mac
- 30+ Zoom video communications application shortcuts for macOS
- How to install wget on macOS
- Mac turn dark mode on or off using terminal command
- Create Symbolic Link using Terminal Command
- Mac - How to Install VirtualBox
- How to Enable or Disable Dark Mode on macOS Ventura 13
- How to install homebrew (brew) on M1 Mac
- How to uninstall Microsoft Outlook on Mac
- JavaScript: Count Words in a String - JavaScript
- List of 60 useful FTP Client Commands to access server - FTP
- Spell check not working in Gmail : Mac OS X - Mac-OS-X
- MySQL Error :1007 SQLSTATE: HY000 (ER_DB_CREATE_EXISTS) Message: Can't create database '%s'; database exists - MySQL
- Add imports in eclipse shortcut key combinations - Eclipse
- Disable jQuery button after being click - jQuery
- Install specific JRE on Ubuntu using apt - Ubuntu
- Parsing CSV file using Java code example (Comma Separated File) - Java