Sudoers file explanation

Dears,

I wolud like if someone could explain to me sudoers file. I have learned the sudoers file format:

%wheel ALL=(ALL) ALL
user/group host=(run as user) command_list

What is a purpose of the (ALL) or run_as_user parameter. Does it mean a command will be executed as a user defined in the parenthesis or not ?

The (ALL) in the middle specifies the users the command can be run as. This is the run_as_user parameter you’ve asked about. In this case, (ALL) means that users in the wheel group can run commands as any user on the system.

Dear @al1 but what if I configure sudoers file like this:

armin   ALL=(al1)  /usr/bin/vi

Does it mean that user armin can run vi editor as user al1 and how can user armin run vi editor as user al1 at all ? This isn’t clear for me :frowning:

Yes that is right, the user armin can run vi as the user al1:

sudo -u al1 vi
1 Like

Dear @al1 thank You. I understand now.