Sanvi
Sanvi

Reputation: 75

how to run a shell script as different user without promting password

I have a shell script moveInvoice.sh with chmod 777 permission as user test1 and all other scripts are under user test2.

Now I need to call moveInvoice.sh from test2 I tried following

sudo -c 
sudo -u

But all are giving permission denied. Is there any other way to make it run with test2 user ?

once manually I am able to execute then I need to put this in crontab

Upvotes: 1

Views: 1048

Answers (1)

Rob Cha
Rob Cha

Reputation: 139

You can set up a user on Linux to be able to run sudo without a password by adding a NOPASSWD option in visudo.

run sudo visudo as root and then add your user under privilege specification as SOMEUSER ALL=(ALL) NOPASSWD: ALL.

now, SOMEUSER will be able to run sudo commands without a password.

Upvotes: 1

Related Questions