Linux Bash – Allow Another User to Execute Program

bashcentoslinux

I want to allow a particular user to execute a compiled program in my directory. I got his username from cat /etc/passwd. The executable does not write any file but reads a few and gives output on the command line.
How can I achieve this?

Best Answer

If your files are not a secret, you may simply make that folder readable to everyone, or to some group where you will put yourself and the other user.

If you have a scenario with users that should not be allowed access to reading those data, you will have to use a sudo-based strategy, so that the privileged user can run your program by means of for example:

sudo ~user19448/myprogram/runme

First you have to configure your sudo (by means of visudo) with something like:

particular-user ALL=(ALL) NOPASSWD: /home/user19448/myprogram/runme

NOPASSWD avoids you the need to enter your own password, which you probably want.

Related Question