'hdfs: command not found

I am using Centos7 and Hadoop 3.2.1. I have created a new user in Linux. I copied the .bash_profile file from the master user to my new user. But when I try run hdfs commands I am having the following problem:

bash: hdfs: command not found...

the error i see

I think I did something missing about the new user. But I don't know what it is.

And I do not know what can I do now. Could you help me?



Solution 1:[1]

I solved the problem myself. It's about permissions.

Make sure your user's bash_profile file is the same as your other user's bash_profile file. Then log in as root and run this command:

chmod -R 777 /home/hadoop/

By doing this, you gave permission your $HADOOP_HOME directory. Now log in with your new user again and try run hdfs commands, for example: hdfs dfs -ls /

So you can do anything what you want in new user. When your done, revoke permissions you gave.

SO DON'T SHUT DOWN YOUR SERVERS. EVER AND NEVER. NOT YET. Run this code as root:

chmod -R 700 /home/hadoop    
chmod -R 660 /home/hadoop/.ssh

If you don't, you won't start your namenodes and datanodes. Because the permission of the subfolder cannot be more than or equal to the parent folder. And it will be a big problem to fix.

So that's all, and it's worked for my case. Now i can run hdfs commands on my new user. I hope I could help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1