In Linux, I want to allow a normal user to view only one file in a path.

How to give the entry in sudoers file. Is the below one is correct?

user ALL = /bin/cat

user ALL = /bin/cat will give the user permissions to use 'cat' on ANY file, which doesn't sound like what you want. You should specify the specific arguments the user can use as well:

user ALL = /bin/cat /path/to/file

(Note that this means the user will need to specify the full file path as well when running sudo)

You should always use the full path when specifying arguments in sudo, lest you end up giving more permissions than you intended. For instance, user ALL = /bin/cat file would grant the ability to run cat against ANYTHING named "file", not just the one located in "/path/to/". This gets more dangerous when you're talking about other programs such as mv, rm, and vi.

The Ubuntu forums has a nice Sudoers tutorial if you're interested in learning more about creating an effective and secure sudoers file.


no, if you want to allow just for a particluar file, you need to put also the file-path in after /bin.cat in sudoers file.

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.