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
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.