Back to course

Introduction to Linux Shell Scripting (Bash I)

Cyber Security Mastery: From Zero to Hero

Automating Security Tasks with Bash

As a security professional, you will constantly perform repetitive tasks (scanning, log analysis, file manipulation). Bash scripting allows you to automate these tasks.

Bash (/bin/bash) is the most common command interpreter (shell) in Linux.

Creating a Simple Script

A Bash script is just a text file containing a series of commands.

  1. Shebang: The first line must specify the interpreter.
  2. Commands: Followed by standard Linux commands.

bash #!/bin/bash

This is a comment

echo "Hello, Kali!" pwd ls -a

Execution

  1. Save the file (e.g., first_script.sh).
  2. Grant execute permission:

bash chmod +x first_script.sh

  1. Run the script:

bash ./first_script.sh