Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Retrieving HDFS Groups and users using programming

avatar
Explorer

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.

 

1 ACCEPTED SOLUTION

avatar
Cloudera Employee

Try this

hdfs groups hdfs solr

View solution in original post

3 REPLIES 3

avatar
Cloudera Employee

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

avatar
Explorer

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.

avatar
Cloudera Employee

Try this

hdfs groups hdfs solr