sudo bash script.sh
#Never use sudo inside a script. Instead call the script with sudo access sudo myscript.sh