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!
- Clear Screen shortcut macOS Terminal
- What is macOS Ventura?
- [fix] How to Show file extensions on all files on Mac
- How to Find Where Mac Terminal App is Located?
- AutoSave button not working on Office on Mac (Word, Excel or Powerpoint)
- macOS say command text to speech using various voices and languages
- How to change Ping TTL value on macOS
- Open .bash_profile File in TextEdit using Terminal
- How to know the Safari Version on Mac
- How to Copy full Absolute Path of a File on Mac
- 13.0 MacOS Ventura release date
- Enable spell check in Sublime Text (macOS)
- How to Display Analog Clock on Mac Menu Bar
- How to turn off Location Services macOS Ventura 13
- How to Open VS Code on Mac
- Add Bookmark macOS Safari
- How to Fix cd: too many arguments Error in Terminal: A Step-by-Step Guide
- How to install wget on macOS
- Select Line Number TextEdit on Mac
- Strikethrough Text in Excel for Mac
- How to Enable or Disable Dark Mode on macOS Ventura 13
- How to hide or display Wifi icon in macOS Bug Sur Menu Bar
- How to install Yarn on Mac (macOS)
- How to fix command not found brew (bash, zsh) on macOS Terminal
- How to Schedule Mails in macOS Ventura
- Python: Traverse List Backwards - Python
- How to Restart Mac using Terminal Command - MacOS
- 5 Ways to Loop a Dictionary in Python - Python
- Java: Convert Stream to List - Java
- Change the background of Tkinter label or text - Python
- How to get file path in Idea IntelliJ IDE - Java
- Jupyter Notebook add Table Of Contents (TOC) - Python
- List of PowerShell Cmdlet Commands for Mac - Powershell