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?


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.


I would add new group include that user in it and change files & executable to that group.

  1. Make a group groupadd Group_name

  2. Change group of the file( executable and the ones that will be read) chgrp Group_name file

  3. Make executable available to group members chmod g+x executable_file

  4. Make all files he/she will need to read readable by the group chmod g+r file

  5. Add User & yourself to group useradd -G Group_name username


The best option is that you both need to be in a same group. Lets say you create a group called team and you both guys are member of that group. Then you can allow him to execute it by giving the group execute permission for that program.

Let say you have two users named test and test1

# groupadd team

# usermod -G team test

# usermod -G team test1

Lets say the directory where your program is in as /home/test/programs/program1

Now change the group ownership of the directory and program.

# chown test:test1 /home/test/programs/program1

# chown test:test1 /home/test/programs/

# chmod g+x /home/test/programs/program1

# chmod g+x /home/test/programs/

Now the user test1 will be able to execute the program.

This way is more secure and it prevents others from abusing it.

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.