Script File
A plain text file containing shell commands.
Shell Script · First Basic Script
Shell Scripting · Lesson 4
Create your first shell script step by step. Set executable permission using chmod. Run script in different ways. Common beginner mistakes and solutions.
A shell script is a text file containing a sequence of Linux commands. These commands are executed line by line by the shell.
Scripts help automate tasks, reduce manual work, and ensure consistency across systems.
Linux treats scripts like normal files. To execute a script directly, it must have execute permission.
Without execute permission, the system will block execution for security reasons.
A plain text file containing shell commands.
Required to run a script directly using ./script.sh.
Run using ./script.sh, bash script.sh, or sh script.sh.
Create a new file using a text editor. Here we use nano.
Add a shebang and a simple echo command.
By default, a new file does not have execute permission.
Make the script executable using chmod.
Run the script using ./ when it has execute permission.
You can also execute a script without execute permission.
hello.sh../hello.sh.bash hello.sh.Next lesson: Variables in Shell Scripting