Hadoop Command Not Found: Verify the Install Before Editing PATH
hadoop: command not found is a shell command-discovery failure. First prove that the intended Hadoop distribution actually contains a runnable bin/hadoop script, then compare that installation with what the failing shell resolves. Do not reinstall Hadoop, edit multiple profiles, or troubleshoot Java until you know which stage fails.
From the intended Hadoop distribution root, verify bin/hadoop exists before testing PATH. Then invoke that exact script. This separates missing/wrong distribution, direct-execution, and shell-discovery failures.
cd /path/to/hadoop
ls -l ./bin/hadoop
./bin/hadoop versionInterpret: script missing → wrong/incomplete distribution; script exists but direct invocation cannot start → diagnose that execution error first; version prints → Hadoop is runnable and the remaining hadoop-by-name failure is shell/PATH resolution.
Why this happens
Apache Hadoop commands are scripts in the distribution's bin directory. A shell resolves hadoop by name through its command lookup/PATH. HADOOP_HOME is useful to identify the Hadoop installation for Hadoop configuration and scripts, but setting it alone does not make the shell discover hadoop; the relevant bin directory still has to be resolvable.
Diagnose before changing more
If not, PATH cannot fix it. Confirm the extraction/install location and that you are not standing in a source tree, parent directory or incomplete package.
If yes, the script is runnable and command discovery is the remaining issue. If it starts and then reports Java/configuration errors, command discovery has already succeeded.
It should point to the directory that contains bin, etc and other Hadoop directories.
That is a different stage: command discovery succeeded, so troubleshoot Java/Hadoop configuration separately.
If so, fix PATH precedence or remove the stale entry rather than stacking another Hadoop bin directory ahead of it blindly.
Inspect PATH in that exact process. Interactive shell startup files are not universal environment configuration.
Fix #2 — set HADOOP_HOME and PATH for the current shell
Point `HADOOP_HOME` to the real Hadoop installation and prepend its `bin` directory to PATH. Use your actual installation path.
export HADOOP_HOME=/path/to/hadoop
export PATH="$HADOOP_HOME/bin:$PATH"
command -v hadoop
hadoop versionVerify: Run command -v hadoop and hadoop version in the same shell. Both should resolve the intended installation.
Fix #3 — persist only the environment that already worked
After the temporary values work, identify the startup file actually read by the shell/session where you need Hadoop. For an interactive bash/zsh terminal that may be a file such as ~/.bashrc or ~/.zshrc, but login shells, IDE terminals, SSH, services and automation can have different startup behavior. Do not copy the exports into every profile file.
hadoop versionVerify: Open a new terminal and run hadoop version again. The command should still resolve without manually exporting variables first.
Fix #4 — works in your terminal, fails in IDE, SSH, service or automation
Run the same discovery checks inside the failing environment. A successful interactive terminal proves only that that process has the right PATH. IDE terminals, remote sessions, schedulers, services and containers can inherit a different environment and may not read your usual shell startup file.
printf '%s\n' "$SHELL"
printf '%s\n' "$PATH"
command -v hadoop || true
command -v java || trueVerify: rerun the exact command/job/service context that originally reported hadoop: command not found. Do not treat success in a different terminal as final verification.
What not to do
hadoop discoverable by the shell.Do not add PATH entries for a directory until you have proved that directory actually contains the intended bin/hadoop.Do not copy Hadoop exports into every shell profile to fix one environment; identify which startup path the failing process actually uses.Still seeing the error?
If `command -v hadoop` returns a path but Hadoop itself fails, the command-not-found problem is solved. Continue with the new error message, such as Java configuration, permissions or Hadoop configuration, rather than adding more PATH entries.
ls -l ./bin/hadoop from the intended distribution rootwhether the failure is interactive shell, IDE, SSH, service, scheduler or containerthe first new error after command discovery succeeds, especially Java/configuration errorsOfficial references
Still stuck? Ask the community
Share your operating system, software version, exact error text, and which fix you already tried. Another reader may have seen the same setup.
Loading community discussion…
Comments could not load here. Open ErrorHarbor Discussions on GitHub →