Skip to main content
phir1
Silver ⭐️⭐️
September 8, 2022
Solved

Retrieving HDFS Groups and users using programming

Hello,

Is there a way to retrieve all HDFS groups and respective users, in Cloudera, using Java or Scala/Spark code?

In other words, I’m looking for Java/Scala code equivalent to "hdfs groups <user1>, <user2>, ...".

Ideally, the code would run in Zeppelin.

Many thanks.

 

James G
James GAnswer
Gold ⭐️
September 8, 2022

Try this

hdfs groups hdfs solr

3 replies

ale241290xdf
Silver ⭐️⭐️
Silver ⭐️⭐️
September 8, 2022

@phir1 
I can think of something like a for maybe:
# for i in `cat <users_file>`; do hdfs groups $i; done

Translate
phir1
phir1Author
Silver ⭐️⭐️
September 8, 2022

Hi,

thank you for your suggestion, but I’m looking for example Java or Scala code that uses the Hadoop or Cloudera API, instead of scripting the « hdfs » tool on Linux.

Translate
James G
Gold ⭐️
James GAnswer
Gold ⭐️
September 8, 2022

Try this

hdfs groups hdfs solr

Translate