Ubuntu: hadoop command not found

17,654

Solution 1

Your current working directory is probably not part of your path. That is default on linux systems.

If you are in the same directory, where your hadoop file is, run that command with an relative path, like: ./hadoop

Solution 2

HOME DIRECTORY:

/home/hadoop is a home directory created by linux similar to Document and settings in windows.

Open your terminal and type:

ls -l /home/hadoop

Post your result for this command: ls -l /home/hadoop

SETTING GLOBAL PATH:

Go to /home/hadoop and open .bashrc in text editor. Add these lines at the end:

export HADOOP_HOME=/path/to/your/hadoop/installation/folder
export PATH=$PATH:$HADOOP_HOME/bin

Save and exit. Now type, this in your teminal:

echo $PATH
echo $HADOOP_HOME

If these commands shows correct directories, try hadoop command. It should work.

Post your result for these command: echo $PATH and echo $HADOOP_HOME

Solution 3

  1. Go to Hadoop-x.x.x/bin folder
  2. check for hadoop folder there
  3. run ./hadoop version

Solution 4

You must run “hadoop version” command.

If the hadoop setup is fine, then you should see the following result:

Hadoop 2.4.1 
Subversion https://svn.apache.org/repos/asf/hadoop/common -r 1529768 
Compiled by hortonmu on 2013-10-07T06:28Z 
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4 

For installation related guide you can refer here:

Hadoop Environment Setup

Link to my quora answer https://qr.ae/TWngHN

Hope this helps.

Thanks

Share:
17,654
Alexis Eggermont
Author by

Alexis Eggermont

Updated on June 28, 2022

Comments

  • Alexis Eggermont
    Alexis Eggermont almost 2 years

    I am trying to check my installation of hadoop. I did create the environment variables and when I call printenv, I do see my HADOOP_HOME and PATH variables printed and correct (home/hadoop and HADOOP_HOME/bin respectively).

    If I go to home/hadoop in the terminal and call ls, I see the hadoop file there. If I try to run it by calling hadoop, it still tells me command not found.

    First day on Linux, so there may be a stupid answer to this problem.

  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    I am just trying to set up hadoop on my ubuntu machine and I was following this link tutorial. After modifying the configuration files mentioned in the tutorial, when I run hadoop version it still gives me hadoop: command not found. The results for the commands posted in this answer are in the following comment.
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    ls -l /home/hadoop total 44 drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Desktop drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Documents drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Downloads -rw-r--r-- 1 hadoop hadoop 8980 ජන 7 13:19 examples.desktop drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Music drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Pictures drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Public drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Templates drwxr-xr-x 2 hadoop hadoop 4096 ජන 7 13:20 Videos
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    echo $PATH /usr/local/hadoop/sbin$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin‌​:/usr/games:/usr/loc‌​al/games:/usr/local/‌​hadoop/sbin:/usr/loc‌​al/hadoop/bin:/usr/l‌​ocal/hadoop/sbin:/us‌​r/local/hadoop/bin echo $HADOOP_HOME /usr/local/hadoop
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    When I extracted the hadoop zipped file, there were no file under the name hadoop. I downloaded the version 2.6.0
  • Rajesh N
    Rajesh N over 8 years
    Post the result for ls -l /usr/local/hadoop/bin and ls -l /usr/local/hadoop/sbin
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    bin is not found. sbin has these -rw-r--r-- 1 root root 2752 19:46 distribute-exclude.sh -rw-r--r-- 1 root root 6452 19:46 hadoop-daemon.sh -rw-r--r-- 1 root root 1360 19:46 hadoop-daemons.sh -rw-r--r-- 1 root root 1640 19:46 hdfs-config.cmd -rw-r--r-- 1 root root 1427 19:46 hdfs-config.sh -rw-r--r-- 1 root root 2291 19:46 httpfs.sh -rw-r--r-- 1 root root 2059 19:46 kms.sh -rw-r--r-- 1 root root 4080 19:46 mr-jobhistory-daemon.sh
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    and these -rw-r--r-- 1 root root 1648 19:46 refresh-namenodes.sh -rw-r--r-- 1 root root 2145 19:46 slaves.sh -rw-r--r-- 1 root root 1779 19:46 start-all.cmd -rw-r--r-- 1 root root 1471 19:46 start-all.sh -rw-r--r-- 1 root root 1128 19:46 start-balancer.sh -rw-r--r-- 1 root root 1401 19:46 start-dfs.cmd -rw-r--r-- 1 root root 3705 19:46 start-dfs.sh -rw-r--r-- 1 root root 1357 19:46 start-secure-dns.sh -rw-r--r-- 1 root root 1571 19:46 start-yarn.cmd -rw-r--r-- 1 root root 1347 19:46 start-yarn.sh
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    -rw-r--r-- 1 root root 1770 19:46 stop-all.cmd -rw-r--r-- 1 root root 1462 19:46 stop-all.sh -rw-r--r-- 1 root root 1179 19:46 stop-balancer.sh -rw-r--r-- 1 root root 1455 19:46 stop-dfs.cmd -rw-r--r-- 1 root root 3206 19:46 stop-dfs.sh -rw-r--r-- 1 root root 1340 19:46 stop-secure-dns.sh -rw-r--r-- 1 root root 1642 19:46 stop-yarn.cmd -rw-r--r-- 1 root root 1340 19:46 stop-yarn.sh -rw-r--r-- 1 root root 4295 19:46 yarn-daemon.sh -rw-r--r-- 1 root root 1353 19:46 yarn-daemons.sh
  • Rajesh N
    Rajesh N over 8 years
    All these files should be owned by hadoop user and not root user. Change the ownership of hadoop folder first and then try hadoop command. It should work. Try this in terminal: sudo chown -R hadoopusername:hadoopgroupname /usr/local/hadoop... Note: If it asks for password, enter your root password and change whatever you have given for hadoop username and groupname respectively.
  • Rajesh N
    Rajesh N over 8 years
    If you haven't created hadoop group and user, please read Adding dedicated hadoop system user section in michael-noll.com/tutorials/…
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    I tried it and changed ownership. (partial content of the folder is shown below) -rw-r--r-- 1 hadoop-ranji hadoop 2752 ජන 7 19:46 distribute-exclude.sh -rw-r--r-- 1 hadoop-ranji hadoop 6452 ජන 7 19:46 hadoop-daemon.sh -rw-r--r-- 1 hadoop-ranji hadoop 1360 ජන 7 19:46 hadoop-daemons.sh -rw-r--r-- 1 hadoop-ranji hadoop 1640 ජන 7 19:46 hdfs-config.cmd -rw-r--r-- 1 hadoop-ranji hadoop 1427 ජන 7 19:46 hdfs-config.sh But still the hadoop command does not work. hadoop: command not found
  • Rajesh N
    Rajesh N over 8 years
    Did you try hadoop command as hadoop-ranji user? If you have executed hadoop command as hadoop-ranji user and still get commad not found, then try this sudo chmod -R 777 /usr/local/hadoop.
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    Yes, I tried it as hadoop-ranji user and after changing permissions, still I am getting command not found
  • Rajesh N
    Rajesh N over 8 years
    I assume your hadoop installation folder does not have bin folder. If so, try downloading it again from archive.apache.org/dist/hadoop/core/hadoop-2.6.0/… . Not the hadoop-2.6.0-src.tar.gz one.
  • Rajith Gun Hewage
    Rajith Gun Hewage over 8 years
    As I mentioned in a previous comment, my installation did not have the bin folder. The download you mentioned worked I guess. I don't get the hadoop: command not anymore.