How to grant specific command permissions?

QuestionsQuestions8 SkillsProUser Account ManagementSep, 27 2025
0109

To grant a user specific command permissions using sudo, you can edit the /etc/sudoers file with the visudo command. This allows you to specify which commands a user can run with sudo.

Steps to Grant Specific Command Permissions:

  1. Open the sudoers file:

    sudo visudo
  2. Add the specific command permission: Use the following syntax to grant a user permission to run a specific command:

    username ALL=(ALL) /path/to/command

    Replace username with the actual username and /path/to/command with the full path of the command you want to allow.

  3. Example: To allow a user named bob to run the apt-get install command without needing a password, you would add:

    bob ALL=(ALL) NOPASSWD: /usr/bin/apt-get install
  4. Save and Exit: After making your changes, save the file and exit.

Important Notes:

  • Full Path: Always use the full path to the command to avoid ambiguity.

  • Multiple Commands: You can specify multiple commands by separating them with commas:

    bob ALL=(ALL) NOPASSWD: /usr/bin/apt-get install, /usr/bin/apt-get remove
  • Security: Be cautious when granting permissions to ensure you do not inadvertently give excessive privileges.

0 Comments

no data
Be the first to share your comment!