visudo + read access to file from non root user

how to access file by visudo from non root user , or other option

for example

when we change user to hdfs
and from user hdfs we want to print the file – file.cfg we get Permission denied

how to configure the visudo in order to get read access from user – hdfs ( and without to use sudo command )

# su hdfs
$ whoami
hdfs
$ pwd
/opt/home/security
$ cat file.cfg
cat: sec.cfg: Permission denied

$ ls -ltr

file is ended with dot:

-rwxr-----. 1 root root   sec.cfg

expected output

# su hdfs
$ pwd
/opt/home/security
cat file.cfg

app_q 384273462 pass BHYVF^GTYR&GV@yhgb2yr

Answer

Check your file permissions unless user hdfs is in group root.

Add read permission to others with chmod 0744 /opt/home/security/file.cfg or add your user to group root.

Attribution
Source : Link , Question Author : jango , Answer Author : deagh

Leave a Comment