Fix Command Not Found on Linux: A Beginner Guide
Before you begin
- Applies to:Ubuntu 26.04 LTS and Red Hat Enterprise Linux (RHEL) 10. Use the package query for your distribution in Step 2.
- Where to start:Use the Bash terminal where the error appeared, under your regular account.
- What you need:Copy the exact command name from the error. Step 1 uses git as an example.
Guide tools
Troubleshooting Steps
Check the spelling and Bash lookup
Start hereIn the Bash shell where the error appeared, set tool to the exact command name. Keep this shell open for Step 3. It prints a path or identifies a shell command if Bash can find it. If it prints nothing, check the spelling, then inspect PATH. PATH is the colon-separated list of directories Bash searches for executable files.
What you should see · A path or shell command appears for the exact name you entered.
If you see something else · If a path appears, use Step 3 to verify that it is the intended program. If nothing appears, go to Step 2 to check the package or the script’s location.
tool=gitcommand -v "$tool"printf '%s\n' "$PATH"Check the package or use an explicit path
Narrow the causeRun only the package query for your distribution. Replace git with the package name that provides your command, which can differ from the command name. On Ubuntu, look for the status install ok installed. A status ending in config-files means the package was removed and residual configuration remains. On RHEL, rpm -q reports whether the package is installed. If the package is absent, confirm the official package name before installing via your system’s package manager. If your tool is a script in the current folder, use its explicit path, such as ./tool, after checking its origin and permissions. For an installed program missing from PATH, confirm its actual directory before editing any shell startup files.
# Ubuntudpkg-query -W -f='${Status} ${Package}\n' git
# RHELrpm -q gitVerify in the same shell
VerifyAfter the approved installation or path correction, repeat command -v. Check that its result points to the expected location, then run the version command for a trusted program. If the tool works in a new terminal only, check how the current shell was started and whether it loaded the same configuration.
command -v "$tool"# For a trusted tool that supports --version:"$tool" --versionReference
Your feedback keeps these production procedures accurate and battle-tested.