This is what I\'m trying to do in a script. It works here manually, but prompts me for a password. How do I:
You don't need sudo su centos
because your script would be interrupted by a terminal.
If the following commands are actually "./install.sh" (like) that have to be started by "centos" user, then you can do the following modification:
sudo adduser centos
sudo passwd centos
usermod -aG wheel centos
sudo su - centos -c ./install.sh
sudo su - centos -c ./install_another.sh
sudo su - centos -c "./install_more.sh ; cd /tmp ; ./install_almostlast.sh"
sudo su - centos -c bash -c "cd /somewhere; ./install_more.sh
cp /tmp/files /somewhere
./install_last.sh
rm /tmp/install.sh"
Between double quotes you can write a whole script if you want and are careful of the content and quoting.