How do you make a script executable?

Answer

Use chmod +x scriptname.sh to add execute permission for the owner (and group/others based on umask). More specific: chmod u+x script.sh (owner only), chmod 755 script.sh (owner rwx, others r-x). After that, run it with ./script.sh (the ./ prefix is required to run executables in the current directory, since . is typically not in PATH for security reasons). Scripts with proper shebangs can also be placed in a directory listed in $PATH (like /usr/local/bin/) to be callable by name from anywhere.