how to access the file by visudo from non root user

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

# su hdfs
$ whoami
$ pwd
$ cat file.cfg
cat: sec.cfg: Permission denied

$ ls -ltr

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

expected output

# su hdfs
$ pwd
cat file.cfg

app_q 384273462 pass BHYVF^GTYR&GV@yhgb2yr

You need e.g. this line in the sudo configuration:

hdfs   ALL=(ALL) NOPASSWD: /bin/cat /opt/home/security/file.cfg

and then run these commands:

su hdfs
sudo /bin/cat /opt/home/security/file.cfg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.