Hadoop commands
hadoop, hdfs
Solution
In unix an executable file can be executed in two ways, either by giving the absolute/relative path or commands in system executables path(path should be specified in PATH variable)
When you execute `bin/hadoop dfs -ls` should be inside the directory /usr/local/hadoop. Or `/usr/local/hadoop/bin/hadoop dfs -ls` will also work
There is one environment variable PATH in unix which keeps in the list of executable location by default it keeps the following path `/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:` . Whenever we execute any command like ls, mkdir etc it is taking from the one location in PATH variable. When you give the command hadoop(it will be taken from the path /usr/local/hadoop/bin/). Since you have specified the path /usr/local/hadoop/bin/ in PATH variable. Use the following command to check the value of your PATH variable
echo $PATH
Problem
I have Hadoop installed in this location /usr/local/hadoop$ Now I want to list the files inside the dfs. The command I used is : hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -ls This gave me the files in the dfs ``` Found 3 items drwxr-xr-x - hduser supergroup 0 2014-03-20 03:53 /user/hduser/gutenberg drwxr-xr-x - hduser supergroup 0 2014-03-24 22:34 /user/hduser/mytext-output -rw-r--r-- 1 hduser supergroup 126 2014-03-24 22:30 /user/hduser/text.txt ``` Next time, I tried the same command in a different manner hduser@ubuntu:/usr/local/hadoop$ hadoop dfs -ls It also gave me the same result. Could some one please explain why both are working despite of executing the ls command from different folders. I hope you guys understood my question.Just explain me difference between these two : ``` hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -ls hduser@ubuntu:/usr/local/hadoop$ hadoop dfs -ls ```