
Since I am using Windows Subsystem for Linux (WSL), I have to constantly run the same set of few commands at the start of Ubuntu. I thought of automating them by executing them as a bash script.
Let's see how to create a bash script that can be executed through the command line with a few keystrokes.
1. Create an empty file with .sh extension
2. Add #! /bin/bash to the start of the script followed by the commands you want to execute
3. Save the file using CTRL+X and press Y and Enter
The file is not yet executable. You can verify it by executing the ls -lrt command.
4. Make the script executable using chmod
5. Verify executable status using ls -lrt
The filename color will change from white to green to indicate it’s executable.
6. Execute the script
Use the command ./script.sh
Post a Comment