Today, we are going to make a simple executable bash shell script. .sh files are shell executables files, that are used in many variations of UNIX-like operating systems. These scripts are equivalent to the bat files on windows.
How to make a executable bash script ?
We are going to make permission script. This script will provide the right permissions for our laravel project. 🙂
First, let’s create a .sh file . Paste the below code in the file and save naming ‘permission.sh’ or whatever you want to.
sudo chown $USER:$USER .env
sudo chown -R $USER:www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
This script cannot run right now. We need to make this script executable.
sudo chmod +x permission.sh
To execute the script, enter the command :
Allright, the script is ready. 🙂 We can add an alias too. Let’s make an alias for that.
Add this at the end of the file:
Now, open a new session terminal or source ~/.bashrc . The alias is ready
grant-permission is the name for my alias. You can put whatever name for the alias. The script is ready , you can go to the laravel root folder and hit the alias. This will manage your permission 🙂
If you want to know the commands written on the scripts then, we have an article for this exact commands for you, click here. Happy Coding 🙂