LearnBashScriptingWithMe π
Day 1 β Introduction, Shebang & File Permissions
Bash scripting is the process of creating a file that contains a sequence of commands and then running that file as a script.
A shell in Kali Linux is a command-line interpreter that provides an interface for the user to interact with the operating system. It allows users to execute commands, scripts, and programs to manage the system, navigate the file system, and perform various administrative tasks.
π We start by creating a file using the βshβ extension as this is used to denote that we are creating a shell script, e.g test.sh
π After that the next thing we need to do is to define the kind of interpreter we are going to be using and for this, the interpreter is BASH and we denote that using
#!/bin/bash
π Inside the script, we can use the echo command to display output. For example, printing βHello World!β
echo "Hello World!"
π Now we can now save and run the script by using the command β./(filename)β
e.g:
./test.sh
Note that the command "./" is telling the shell to use the interpreter defined in the file we want to run which was what was defined first when we wrote "#!/bin/bash" in the file
But noticeβyou might get a βpermission deniedβ error. Thatβs because the file isnβt yet executable.
π To fix this, grant execution permission with:
chmod +x test.sh
Now, when you run ./test.sh, the script executes successfully π
Top comments (0)