Introduction
Running scripts lets you tell your computer to do many tasks automatically, saving time and effort.
# To run a script named script.sh ./script.sh # Or run it with bash explicitly bash script.sh
chmod +x myscript.sh ./myscript.sh
bash myscript.sh
/home/user/scripts/myscript.sh
#!/bin/bash # This script prints a greeting echo "Hello, friend! Running scripts is easy!"
myscript.sh after making it executable?./myscript.sh, it must have execute permission set using chmod +x myscript.sh../myscript.sh runs the script in the current directory. Other commands like run, execute, or start are not valid bash commands../myscript.sh to run the script. -> Option A./script.sh = A [OK]backup.sh without changing its permissions?bash backup.sh.bash backup.sh runs the script using bash without needing execute permission. Other options either require execute permission or are invalid commands.bash backup.sh -> Option Chello.sh with content:#!/bin/bash echo "Hello, $1!"
./hello.sh World?$1 which is the first argument passed to the script. Here, World is passed as the first argument.$1 with the argument../myscript.sh but get Permission denied. What is the most likely fix?chmod +x myscript.sh to add execute permission, allowing the script to run.chmod +x myscript.sh. -> Option Adeploy.sh located in /home/user/scripts from anywhere in the terminal without typing the full path. What is the best way to do this?/home/user/scripts to PATH, you can run deploy.sh from anywhere simply by typing deploy.sh./home/user/scripts to the PATH environment variable. -> Option DPass the test and this pattern moves unknown