You are on page 1of 1

To give a user restricted sudo access in Linux, you can modify the sudoers file using the

visudo command. Here's how you can do it:

1. Open a terminal and run the following command to edit the sudoers file:

sudo visudo

Locate the section in the sudoers file where user privileges are defined. It should have a line that
looks like:

root ALL=(ALL:ALL) ALL

Below the root entry, add a new line for the user you want to grant restricted sudo access.
Replace <username> with the actual username of the user:

<username> ALL=(ALL) /path/to/allowed/command

Replace /path/to/allowed/command with the full path to the specific command or commands that
the user is allowed to execute with sudo . For example, if you want to allow the user to run the ls
command, the line would look like this:

<username> ALL=(ALL) /bin/ls

1. You can specify multiple commands by separating them with commas.


2. Save the sudoers file and exit the editor.

After making these changes, the user will have restricted sudo access and will only be
able to execute the specified command(s) with sudo. They won't have full administrative
privileges. Make sure to double-check the syntax and save the file correctly, as incorrect
changes to the sudoers file can cause issues with system administration.

You might also like