
How To Make A Shell Script Executable On The Raspberry Pi
1
Navigate to the file
Navigate to the path of the directory where the file is:
cd ~/some/directoryYou can confirm that the file is not executable by running ls -la, and observing there’s no x (for executable):
-rw-r--r-- 1 pi pi 684 Dec 16 17:28 install.sh2
Make the script executable
To make the script executable, use the chmod command:
sudo chmod +x install.shIf you run ls -la, you’ll see the file is now executable:
-rwxr-xr-x 1 pi pi 684 Dec 16 17:28 install.shYou’ll now be able to execute the script successfully:
sudo ./install.shIt’s worth mentioning that the file doesn’t have to be executable to run it. You can also use sudo sh install.sh, but making it executable is handy in order to execute the script directly.