I am running a script as a root that creates a user using useradd
and passwd
. Then am doing some checks/installs before running some other commands that need to be run as the newly created user.
So I have the main script that creates the user:
main.sh:
#!/bin/bash
useradd testuser
passwd testuser
yum -y install git
chmod 777 testuser.sh
su testuser -c ./testuserscript.sh
testuserscript.sh:
#!/bin/bash
git clone git://github.com/schacon/grit.git
When I run ./main.sh: I get the the following error:
bash: ./testuserscript.sh: Permission denied
When I do ll I get the following:
-rwxrwxrwx. 1 root root 728 Jun 24 11:02 testuserscript.sh
Am I running the wrong command to run the testscript
as the testuser
?