Hadoop
provides following commands to work with file permissions.
chgrp: Change group association of
files
chmod: Change the permissions of files
chown: Change the owner of files
Each
file/directory in HDFS is associated with a group or owner.
For files
r permission is required to read the
file,
w permission is required to write or
append to the file
For
directories
r permission is required to list the contents of
the directory
w permission is required to create or delete files
or directories
x permission is required to access a child of the
directory
In addition
to read, write and execute permissions, there are 3 kinds of users owner,
group, others for a file/directory in HDFS. We can set permissions for all
three categories of users using the commands mentioned above. When a file or
directory is created, its owner is the user identity of the client process, and
its group is the group of the parent directory
chmod: Change the
permissions of files.
Change the permissions of files. With -R, make the
change recursively through the directory structure.
Usage:
hadoop fs [generic
options] -chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...
$ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-r--r-- 3 harikrishna_gurram w 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt l$ l$ hadoop fs -chmod g+w /user/harikrishna_gurram/dir1/append.txt l$ l$ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-rw-r-- 3 harikrishna_gurram w 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt
chgrp: Change group association of files
Change group
association of files. The user must be the owner of files, or else a
super-user.
Usage:
hadoop fs
[generic options] -chgrp [-R] GROUP PATH...
$ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-rw-r-- 3 harikrishna_gurram w 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt $ $ hadoop fs -chgrp group1 /user/harikrishna_gurram/dir1/append.txt $ $ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-rw-r-- 3 harikrishna_gurram group1 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt
chown: Change owner of files
Change the
owner of files. The user must be a super-user.
Usage
hadoop fs
[generic options] -chown [-R] [OWNER][:[GROUP]] PATH...
$ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-rw-r-- 3 harikrishna_gurram group1 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt $ $ hadoop fs -chown "Phalgun" /user/harikrishna_gurram/dir1/append.txt $ $ hadoop fs -ls /user/harikrishna_gurram/dir1/append.txt -rw-rw-r-- 3 Phalgun group1 20 2015-06-18 12:45 /user/harikrishna_gurram/dir1/append.txt
No comments:
Post a Comment