sudo su error

Hello,

I am logging to a server using username 'test'. I want to execute some commands as user test2.

When I am trying to run `sudo su - test2 -c 'ls'` it gives error user 'test' is not allowed to run sudo in host. But when I login into the account 'test2' using sudo su - test2 all these commands work.

Is there any way I can get this working? I need to do that because I want to run this command from a script. I think it is related to permissions for user test. Please advise.

Regards,
Saura

Ask sysadmin to add test user to sudoers file.

But I am able to sudo su - test2 as test user. Which means test user is in sudo file isnt it?

Thanks for your reply.

Ok then what is the output of sudo -l when you are user test?

sudo -l show that I can execute only sudo - su test2. Editing the sudoers file should solve the problem right?

Is it possible to add an entry such that the user can execute sudo -su test2 -c 'whatever command he wants with options'

Thanks for the reply.

in sudoers file:

test ALL = NOPASSWD : /usr/bin/su - test2 *

Thank you..