Shared HDFS datasets often need one owner to update data while a team can read it. File and directory permissions can grant that team access without making the dataset readable to every cluster user.

HDFS stores separate permission bits for the owner, group, and other users. Reading a file requires read permission on the file and execute permission on every directory in its path; listing a directory also requires directory read permission.

Changes require a client configured for the HDFS cluster and an identity that owns the paths. Changing their group also requires membership in the destination group, unless the caller is an HDFS superuser. Object stores such as S3A use different access controls.

Steps to set HDFS file permissions:

  1. Record the current HDFS metadata for the directory and file.
    $ hdfs dfs -ls -d /data/events /data/events/events.csv
    drwx------   - alice readers          0 2026-11-09 13:34 /data/events
    -rw-------   2 alice readers         28 2026-11-09 13:34 /data/events/events.csv

    The paths represent an existing dataset owned by alice, who belongs to analytics. The -d option lists the directory itself rather than its contents. A + after a mode indicates an extended ACL; if present, hdfs dfs -getfacl shows the additional access rules before a mode-only change.

    Changing the group or mode can expose data to a new team or stop existing jobs from accessing it. The recorded values provide the settings to restore with -chgrp and -chmod if access breaks; the owner or HDFS administrator can restore them.

  2. Assign the directory and file to the analytics group.
    $ hdfs dfs -chgrp analytics /data/events /data/events/events.csv

    The owner remains alice. The cluster's group mapping must already recognize the user's membership in analytics.

  3. Set the directory permissions to 750.
    $ hdfs dfs -chmod 750 /data/events

    750 means rwx for the owner, r-x for the group, and no access for others. Parent directories must also permit the intended user to traverse the path. This change affects only the named directory.

  4. Set the data file permissions to 640.
    $ hdfs dfs -chmod 640 /data/events/events.csv

    640 means owner read-and-write access, group read access, and no access for others. A recursive -R change would affect every descendant, so it is unsuitable when files and directories need different modes.

  5. Confirm the resulting modes and analytics group on both paths.
    $ hdfs dfs -ls -d /data/events /data/events/events.csv
    drwxr-x---   - alice analytics          0 2026-11-09 13:34 /data/events
    -rw-r-----   2 alice analytics         28 2026-11-09 13:34 /data/events/events.csv

    The directory should show drwxr-x— and the file should show -rw-r—–, with analytics as the group.

  6. Read the file from a session belonging to an analytics group member.
    $ hdfs dfs -cat /data/events/events.csv
    event_id,event_type
    1,login

    This read runs as bob, an existing analytics member, using that user's normal cluster authentication. File contents confirm that directory traversal and file reading both work. An HDFS superuser bypasses permission checks, so its successful read cannot establish team access. A Permission denied error means the user's identity, group mapping, parent-directory access, or file permissions still prevent the read.

Share this guide