Skip to content

02 — Bash for Cybersecurity

Bash is one of the most important command-line and scripting environments for Linux-based cybersecurity work.

Security professionals regularly use Bash when working with:

LINUX SERVERS
CLOUD VMs
CONTAINERS
SECURITY TOOLS
LOG FILES
INCIDENT RESPONSE
DEVSECOPS
AUTOMATION
PENETRATION TESTING LABS

The goal of this module is not to memorize hundreds of Linux commands.

The goal is to understand how to combine small commands into repeatable security workflows.

The core Bash model is:

COMMAND
OUTPUT
PIPE
FILTER
PROCESS
RESULT

For example:

SECURITY LOG
grep
FILTER FAILED LOGINS
awk
EXTRACT USERS
sort
uniq
COUNT EVENTS

This is where Bash becomes extremely useful.

Bash gives you direct access to:

FILES
DIRECTORIES
PROCESSES
SERVICES
PERMISSIONS
NETWORK CONNECTIONS
LOGS
SYSTEM CONFIGURATION

It is therefore especially valuable for:

Security Engineers
SOC Analysts
Cloud Security Engineers
Penetration Testers
Incident Responders
DevSecOps Engineers
Linux Administrators
Threat Hunters

Follow this sequence:

LINUX SHELL
FILES
DIRECTORIES
PERMISSIONS
PROCESSES
SERVICES
PIPES
REDIRECTION
grep
cut
sort
uniq
awk
sed
VARIABLES
CONDITIONS
LOOPS
FUNCTIONS
ARGUMENTS
NETWORK COMMANDS
LOG ANALYSIS
SECURITY AUTOMATION

Run:

Terminal window
echo "$SHELL"

You may see:

/bin/bash

Check Bash version:

Terminal window
bash --version

The shell sits between:

YOU
COMMAND
SHELL
OPERATING SYSTEM

Example:

Terminal window
whoami

The shell interprets the command and displays the result.

Start with:

Terminal window
whoami

Then:

Terminal window
id

Then:

Terminal window
hostname

Then:

Terminal window
pwd

These answer:

WHO AM I?
WHAT GROUPS DO I HAVE?
WHICH HOST AM I ON?
WHERE AM I?

View your shell history:

Terminal window
history

Security professionals should remember that shell history may contain sensitive information.

Avoid placing:

PASSWORDS
API KEYS
TOKENS
PRIVATE SECRETS

directly into commands where possible.

Show current directory:

Terminal window
pwd

List contents:

Terminal window
ls

Detailed view:

Terminal window
ls -la

Change directory:

Terminal window
cd /var/log

Return home:

Terminal window
cd ~

Create:

Terminal window
mkdir -p ~/bash-cybersecurity

Move into it:

Terminal window
cd ~/bash-cybersecurity

Create folders:

Terminal window
mkdir logs scripts reports evidence

Your structure becomes:

bash-cybersecurity/
|
+-- logs/
|
+-- scripts/
|
+-- reports/
|
+-- evidence/

Create a file:

Terminal window
touch notes.txt

View:

Terminal window
cat notes.txt

Write:

Terminal window
echo "Security lab started" > notes.txt

Append:

Terminal window
echo "Log analysis completed" >> notes.txt
COMMAND OUTPUT
>
FILE

> overwrites.

>> appends.

Linux commands typically use:

STDIN
STDOUT
STDERR

Conceptually:

INPUT
COMMAND
├── STANDARD OUTPUT
└── STANDARD ERROR

Redirect normal output:

Terminal window
command > output.txt

Redirect errors:

Terminal window
command 2> errors.txt

Redirect both:

Terminal window
command > output.txt 2>&1

Copy:

Terminal window
cp notes.txt evidence/

Move:

Terminal window
mv notes.txt reports/

Rename:

Terminal window
mv old.txt new.txt

Remove:

Terminal window
rm file.txt

Directories:

Terminal window
rm -r directory/

Be cautious with:

Terminal window
rm -rf

especially when running with elevated privilege.

Always verify:

Terminal window
pwd

and the exact target before destructive operations.

Use:

Terminal window
file <filename>

Example:

Terminal window
file security.log

This can help identify whether something is:

TEXT
EXECUTABLE
ARCHIVE
IMAGE
BINARY

Use:

Terminal window
stat security.log

This provides:

Size
Owner
Permissions
Timestamps
Filesystem Information

Run:

Terminal window
ls -l

Example:

-rw-r----- 1 analyst security 1024 Aug 29 security.log

Interpret:

OWNER
GROUP
OTHERS

with:

READ
WRITE
EXECUTE

Common numeric values:

4 = Read
2 = Write
1 = Execute

Example:

750

means:

OWNER
rwx
GROUP
r-x
OTHERS
---

In your own lab:

Terminal window
chmod 640 security.log

For a script:

Terminal window
chmod 750 script.sh

Use:

Terminal window
ls -l

Change ownership only when authorized and required.

Example administrative form:

Terminal window
sudo chown user:group file

Do not change ownership on production systems without approval.

A key Linux security question is:

WHO CAN READ?
WHO CAN WRITE?
WHO CAN EXECUTE?

Especially for:

CONFIGURATION FILES
SCRIPTS
SERVICE FILES
LOGS
CREDENTIAL FILES
PRIVATE KEYS

Find by name:

Terminal window
find . -name "*.log"

Find directories:

Terminal window
find . -type d

Find files:

Terminal window
find . -type f

For incident response in an authorized system:

Terminal window
find . -type f -mtime -1

This finds files modified within approximately the last day.

Example:

Terminal window
find . -type f -size +10M

Useful for:

LOG REVIEW
DISK INVESTIGATION
EVIDENCE COLLECTION

In your own lab:

Terminal window
find . -type f -perm -002

This identifies world-writable files in the current tree.

Do not assume every result is automatically a vulnerability.

The pipe operator:

|

passes output from one command into another.

Example:

Terminal window
cat security.log | grep "FAILED"

More simply:

Terminal window
grep "FAILED" security.log
COMMAND A
OUTPUT
|
COMMAND B

grep is one of the most useful Linux security commands.

Example:

Terminal window
grep "FAILED" security.log

Case-insensitive:

Terminal window
grep -i "failed" security.log

Show line numbers:

Terminal window
grep -n "FAILED" security.log

Search through a directory you are authorized to inspect:

Terminal window
grep -R "ERROR" ./logs

Useful for:

LOGS
APPLICATION CONFIGURATION
INCIDENT REVIEW

Avoid broad secret-hunting across systems without a legitimate need.

Show lines not matching:

Terminal window
grep -v "INFO" security.log

This can remove noise.

Terminal window
grep -c "FAILED" security.log

cut extracts fields.

Example file:

admin01,10.10.10.20,FAILED
user01,10.10.10.30,SUCCESS

Extract first column:

Terminal window
cut -d',' -f1 events.csv

Sort lines:

Terminal window
sort users.txt

Numeric sort:

Terminal window
sort -n numbers.txt

Reverse:

Terminal window
sort -r users.txt

Remove adjacent duplicates:

Terminal window
sort users.txt | uniq

Count:

Terminal window
sort users.txt | uniq -c
Terminal window
cut -d',' -f1 events.csv | sort | uniq -c

This can count events by user.

First lines:

Terminal window
head security.log

Last lines:

Terminal window
tail security.log

Last 20 lines:

Terminal window
tail -n 20 security.log

For your own lab:

Terminal window
tail -f application.log

This is useful while validating:

APPLICATION EVENTS
AUTHENTICATION EVENTS
SERVICE ACTIVITY

Stop with:

Ctrl+C

Count lines:

Terminal window
wc -l security.log

Count words:

Terminal window
wc -w security.log

awk is powerful for structured text processing.

Suppose:

FAILED admin01 10.10.10.20
SUCCESS user01 10.10.10.30

Extract username:

Terminal window
awk '{print $2}' security.log

Extract IP:

Terminal window
awk '{print $3}' security.log
Terminal window
awk '$1 == "FAILED" {print $2, $3}' security.log

This prints users and IPs for failed events.

Example:

Terminal window
awk '$1 == "FAILED" {print $2}' security.log |
sort |
uniq -c |
sort -nr

Workflow:

LOG
FILTER FAILED
EXTRACT USER
SORT
COUNT
RANK

sed transforms text.

Example:

Terminal window
sed 's/FAILED/LOGIN_FAILURE/g' security.log

By default this prints the transformed result rather than changing the original file.

Preview first:

Terminal window
sed 's/old/new/g' file.txt

Only modify files in place when you understand the impact and have a backup.

Translate characters.

Example:

Terminal window
echo "HIGH" | tr 'A-Z' 'a-z'

Output:

high

This is useful for normalizing security data.

xargs can convert input into command arguments.

Example:

Terminal window
printf "%s\n" file1.txt file2.txt | xargs -n1 basename

Use caution when input comes from untrusted sources or filenames containing unusual characters.

Create:

Terminal window
username="analyst01"

Print:

Terminal window
echo "$username"

Example:

Terminal window
log_file="./logs/auth.log"
report_file="./reports/failed-logins.txt"
threshold=5

Use descriptive names.

Double quotes expand variables:

Terminal window
echo "$username"

Single quotes do not:

Terminal window
echo '$username'

Understanding quoting is essential for writing safe shell scripts.

Capture command output:

Terminal window
current_user=$(whoami)

Then:

Terminal window
echo "Current user: $current_user"

View:

Terminal window
env

or:

Terminal window
printenv

Common variables:

PATH
HOME
USER
SHELL

Display:

Terminal window
echo "$PATH"

One directory per line:

Terminal window
echo "$PATH" | tr ':' '\n'

Security scripts should avoid relying on unsafe or unexpected command-resolution paths.

Create:

Terminal window
nano scripts/security-check.sh

Start with:

#!/usr/bin/env bash
echo "Security check started"

Make executable:

Terminal window
chmod +x scripts/security-check.sh

Run:

Terminal window
./scripts/security-check.sh

The first line:

#!/usr/bin/env bash

tells the operating system which interpreter should execute the script.

For many automation scripts, consider:

Terminal window
set -euo pipefail

Conceptually:

-e
Stop on unhandled command failure
-u
Fail on unset variables
pipefail
Propagate pipeline failures

Understand how these affect your script before using them.

Example:

Terminal window
failed_logins=8
if [ "$failed_logins" -gt 5 ]; then
echo "Suspicious login activity"
fi
Terminal window
if [ "$failed_logins" -gt 10 ]; then
echo "High risk"
else
echo "Review normally"
fi
Terminal window
if [ "$failed_logins" -ge 10 ]; then
echo "High"
elif [ "$failed_logins" -ge 5 ]; then
echo "Medium"
else
echo "Low"
fi

Common:

-eq Equal
-ne Not equal
-gt Greater than
-lt Less than
-ge Greater or equal
-le Less or equal

Example:

Terminal window
severity="critical"
if [ "$severity" = "critical" ]; then
echo "Escalate"
fi

Check file exists:

Terminal window
if [ -f "$log_file" ]; then
echo "Log found"
fi

Directory:

Terminal window
if [ -d "./logs" ]; then
echo "Logs directory exists"
fi

Readable:

Terminal window
if [ -r "$log_file" ]; then
echo "Readable"
fi

Example:

Terminal window
for host in WEB01 APP01 DB01; do
echo "Reviewing $host"
done
Terminal window
for file in ./logs/*.log; do
echo "Processing $file"
done

Handle cases where no files match carefully in production-quality scripts.

Example:

Terminal window
count=1
while [ "$count" -le 3 ]; do
echo "Iteration $count"
count=$((count + 1))
done

A safer pattern:

Terminal window
while IFS= read -r line; do
echo "$line"
done < security.log

This preserves most input accurately.

Create reusable logic:

Terminal window
show_alert() {
echo "ALERT: $1"
}

Call:

Terminal window
show_alert "Multiple failed logins detected"

Shell functions commonly return a numeric status and print output separately.

Example:

Terminal window
check_file() {
if [ -f "$1" ]; then
return 0
else
return 1
fi
}

Then:

Terminal window
if check_file "security.log"; then
echo "File exists"
fi

Arguments are:

$1
$2
$3

Example:

#!/usr/bin/env bash
log_file="$1"
echo "Analyzing $log_file"

Run:

Terminal window
./analyze.sh security.log

Always validate.

Terminal window
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <logfile>"
exit 1
fi
Terminal window
log_file="$1"
if [ ! -f "$log_file" ]; then
echo "File not found"
exit 1
fi

Convention:

0
=
Success
Non-zero
=
Error / Other Status

Check the previous result:

Terminal window
echo "$?"

AND:

Terminal window
command1 && command2

Second command runs only if the first succeeds.

OR:

Terminal window
command1 || command2

Second command runs if the first fails.

Example:

Terminal window
mkdir -p reports &&
echo "Reports directory ready"

This is useful for predictable automation.

Use:

Terminal window
ps aux

or:

Terminal window
ps -ef

Look for:

User
PID
Process
Arguments
Terminal window
ps aux | grep "application"

A cleaner option may be:

Terminal window
pgrep -a application

when available.

Use:

Terminal window
ps -ef --forest

or:

Terminal window
pstree

This helps understand:

PARENT
CHILD
SERVICE RELATIONSHIPS

On systemd systems:

Terminal window
systemctl --type=service --state=running

Inspect:

Terminal window
systemctl status <service>

View service logs:

Terminal window
journalctl -u <service>

Recent entries:

Terminal window
journalctl -u <service> -n 50

Since today:

Terminal window
journalctl --since today

Depending on distribution, logs may exist at:

/var/log/auth.log
/var/log/secure

Only inspect logs you are authorized to access.

Example:

Terminal window
grep -i "failed" /path/to/training-auth.log

Count:

Terminal window
grep -ic "failed" /path/to/training-auth.log

Example synthetic log:

FAILED admin01 10.10.10.21
FAILED user01 10.10.10.22
FAILED admin01 10.10.10.23
FAILED admin01 10.10.10.21

Run:

Terminal window
awk '$1 == "FAILED" {print $2}' auth.log |
sort |
uniq -c |
sort -nr

Output might be:

3 admin01
1 user01
Terminal window
awk '$1 == "FAILED" {print $3}' auth.log |
sort |
uniq -c |
sort -nr
Terminal window
awk '$1 == "FAILED" {print $2}' auth.log |
sort |
uniq -c |
sort -nr > reports/failed-users.txt
Terminal window
date

Formatted:

Terminal window
date '+%Y-%m-%d %H:%M:%S'

Use in reports:

Terminal window
echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')" \
> reports/report.txt

Use:

Terminal window
sha256sum sample.txt

Security uses:

INTEGRITY
EVIDENCE
IOC COMPARISON
FILE TRACKING
Terminal window
sha256sum evidence/*

Only use files you are authorized to process.

Save:

Terminal window
sha256sum sample.txt > sample.sha256

Verify:

Terminal window
sha256sum -c sample.sha256

Create:

Terminal window
tar -czf evidence.tar.gz evidence/

List contents:

Terminal window
tar -tzf evidence.tar.gz

This can help package lab evidence.

Use:

Terminal window
ip addr

Routes:

Terminal window
ip route

DNS configuration varies by system, but may be reviewed through appropriate resolver configuration.

Use:

Terminal window
ss -lntup

This can show:

Local Address
Port
Protocol
Process

depending on permissions.

Use:

Terminal window
ss -ntp

Review:

Local Endpoint
Remote Endpoint
State

Use:

Terminal window
dig example.com

or:

Terminal window
nslookup example.com

For security labs, use authorized internal names where appropriate.

Use:

Terminal window
curl https://example.com

Headers:

Terminal window
curl -I https://example.com

Verbose:

Terminal window
curl -v https://example.com

Use only against systems you are authorized to interact with.

Example placeholder:

Terminal window
curl \
-H "Accept: application/json" \
https://example.invalid/api/status

Avoid:

Terminal window
curl -H "Authorization: Bearer real-secret" ...

in situations where the token may be exposed in history or process information.

Prefer approved secure secret handling for the environment.

Example:

Terminal window
curl -o file.txt https://example.invalid/file.txt

Only download from trusted and authorized sources.

Verify expected hashes where available.

Use:

Terminal window
df -h

Directory size:

Terminal window
du -sh ./logs

Identify large entries:

Terminal window
du -sh ./* | sort -h

Use:

Terminal window
free -h

and:

Terminal window
uptime

These are useful during:

INCIDENT RESPONSE
SYSTEM TROUBLESHOOTING
SERVICE INVESTIGATION

Run:

Terminal window
env

Be careful when capturing evidence because environment variables may contain sensitive configuration.

Redact secrets.

Example:

Terminal window
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1"
}

Then:

Terminal window
log "Analysis started"
Terminal window
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" \
>> reports/script.log
}

Do not write secrets to logs.

Example:

Terminal window
if ! grep "FAILED" security.log > /dev/null; then
echo "No failed events detected or command failed"
fi

For production scripts, distinguish:

NO MATCH
COMMAND FAILURE

when necessary.

Avoid predictable temporary filenames for sensitive operations.

Use:

Terminal window
mktemp

Example:

Terminal window
temp_file=$(mktemp)

Clean up:

Terminal window
rm -f "$temp_file"

Use trap for cleanup:

Terminal window
temp_file=$(mktemp)
cleanup() {
rm -f "$temp_file"
}
trap cleanup EXIT

This helps remove temporary resources even when the script exits unexpectedly.

Avoid patterns involving:

Terminal window
eval "$user_input"

especially with untrusted data.

It can cause input to be interpreted as shell commands.

Prefer:

Terminal window
rm -- "$file"

not:

Terminal window
rm $file

Quoting helps prevent whitespace and special-character problems.

Some commands support:

--

to indicate the end of options.

Example:

Terminal window
rm -- "$filename"

This is useful when filenames could begin with -.

Do not build scripts around patterns like:

Terminal window
for file in $(ls)

This breaks on spaces and unusual filenames.

Prefer:

Terminal window
for file in ./*; do
...
done

or appropriate find patterns.

A reusable script can follow:

SHEBANG
SAFETY OPTIONS
CONFIGURATION
FUNCTIONS
INPUT VALIDATION
MAIN WORKFLOW
OUTPUT
CLEANUP
#!/usr/bin/env bash
set -u
main() {
echo "Security analysis started"
}
main "$@"

Build:

AUTH LOG
FILTER FAILURES
EXTRACT USERS
COUNT
SORT
REPORT

Example pipeline:

Terminal window
awk '$1 == "FAILED" {print $2}' auth.log |
sort |
uniq -c |
sort -nr

Input:

FAILED admin01 10.10.10.20
FAILED admin01 10.10.10.20
FAILED user01 10.10.10.30

Process:

Terminal window
awk '$1 == "FAILED" {print $3}' auth.log |
sort |
uniq -c |
sort -nr

Output:

Count by Source IP

106 — Project 03: File Integrity Baseline

Section titled “106 — Project 03: File Integrity Baseline”

Create a baseline:

Terminal window
find evidence -type f -exec sha256sum {} \; \
> reports/baseline.sha256

Later compare carefully using your training data.

This introduces the concept of:

FILE INTEGRITY MONITORING

107 — Project 04: Linux Security Inventory

Section titled “107 — Project 04: Linux Security Inventory”

Create a script that records:

Hostname
Current User
OS
Kernel
IP Addresses
Routes
Listening Ports
Running Services
Disk Usage

Do not include secrets.

Build:

INPUT LOG
FAILED EVENTS
ERROR EVENTS
TOP USERS
TOP SOURCES
REPORT FILE

Within your own training directory:

FILES
PERMISSIONS
WORLD-WRITABLE
GROUP-WRITABLE
REPORT

Focus on explaining permissions rather than labeling every writable object a vulnerability.

Collect:

RUNNING SERVICES
LISTENING PORTS
SERVICE NAMES
SYSTEM ROLE

Then manually review whether each service is expected.

111 — Project 08: Evidence Collection Helper

Section titled “111 — Project 08: Evidence Collection Helper”

Build a script that:

Creates Evidence Folder
Records Timestamp
Records Hostname
Records User
Calculates File Hashes
Creates Archive
Generates Evidence Index

Use only inside your authorized lab.

Focus on:

grep
awk
sort
uniq
cut
Log Analysis
IOC Processing
Report Generation

Focus on:

Processes
Network Connections
Recent Files
Hashes
Logs
Services
Evidence Collection

Focus on:

Cloud CLI Output
JSON / Text Processing
Resource Inventory
Configuration Checks
Log Collection
Automation

When structured JSON is available, dedicated parsers such as jq are often preferable to fragile text parsing.

If installed:

Terminal window
jq '.'

can format JSON.

Example:

Terminal window
cat events.json | jq '.'

More simply:

Terminal window
jq '.' events.json

Given:

{
"user": "analyst01",
"severity": "high"
}

Use:

Terminal window
jq -r '.user' event.json

Example array:

Terminal window
jq '.[] | select(.severity == "high")' alerts.json

This is useful for cloud and security API data.

Use Bash when:

The Task Is Shell-Oriented
You Are Combining Linux Commands
The Workflow Is Short
You Need Quick Automation

Use Python when:

Data Structures Become Complex
Logic Becomes Large
You Need Robust APIs
You Need Advanced Error Handling
The Script Must Scale

A useful rule:

IF THE SCRIPT BECOMES
DIFFICULT TO READ,
TEST, OR MAINTAIN

consider moving the workflow to:

PYTHON

or another suitable language.

Always think about:

QUOTING
INPUT VALIDATION
FILE PERMISSIONS
SECRET HANDLING
TEMPORARY FILES
ERROR HANDLING
LEAST PRIVILEGE
CLEANUP

Avoid:

Terminal window
password="real-password"

or:

Terminal window
token="real-token"

in scripts committed to repositories.

Use approved secret-management mechanisms for your environment.

Do not run:

Terminal window
sudo ./script.sh

simply because the script fails.

Determine:

WHICH ACTION
NEEDS ADDITIONAL PRIVILEGE?

and whether that privilege is actually necessary.

Security automation scripts themselves may become sensitive if they:

ACCESS PRIVILEGED DATA
READ CREDENTIAL STORES
MANAGE SERVICES
ACCESS CLOUD APIs

Protect them appropriately.

Before executing an unfamiliar script:

READ IT
UNDERSTAND IT
CHECK INPUTS
CHECK FILE OPERATIONS
CHECK NETWORK OPERATIONS
CHECK PRIVILEGES
CHECK CLEANUP

Do not blindly run copied scripts as root.

Week Focus
1 Shell, Files, Permissions, Pipes
2 grep, awk, sed, sort, uniq
3 Variables, Conditions, Loops, Functions
4 Logs, Networking, Security Automation

Use:

DAY 01
FILES
DAY 02
PERMISSIONS
DAY 03
PIPES
DAY 04
grep
DAY 05
awk
DAY 06
LOG ANALYSIS
DAY 07
MINI PROJECT

Then repeat with more complex security data.

You can use:

pwd
cd
ls
cat
cp
mv

You can combine:

grep
cut
sort
uniq
head
tail
wc

You can use:

awk
sed
jq

appropriately.

You understand:

Variables
Conditions
Loops
Functions
Arguments

You can review:

Processes
Services
Network Connections
Logs
Permissions

You can build scripts that:

Collect
Parse
Analyze
Report
Clean Up
  • Shell identified
  • Current user identified
  • Host identified
  • Working directory understood
  • History understood
  • Create files
  • Read files
  • Copy files
  • Move files
  • Remove files safely
  • File metadata reviewed
  • ls -l
  • Read/write/execute understood
  • Numeric permissions understood
  • Ownership understood
  • chmod understood
  • grep
  • cut
  • sort
  • uniq
  • head
  • tail
  • wc
  • awk
  • sed
  • tr
  • Variables
  • Quoting
  • Command substitution
  • Conditions
  • Loops
  • Functions
  • Arguments
  • Exit codes
  • ps
  • Process tree
  • Process filtering
  • Services
  • systemd
  • Authentication logs
  • Application logs
  • journalctl
  • Filtering
  • Counting
  • Reporting
  • ip addr
  • ip route
  • ss
  • DNS lookup
  • curl
  • SHA-256
  • Archive evidence
  • Timestamp reports
  • Temporary files
  • Cleanup
  • JSON concept understood
  • jq formatting
  • Field extraction
  • Filtering
  • Variables quoted
  • Inputs validated
  • Secrets protected
  • Least privilege used
  • Errors handled
  • Temporary files handled safely
  • Cleanup performed
  • Unfamiliar scripts reviewed before execution
  • Failed login analyzer
  • Suspicious IP summary
  • File integrity baseline
  • Linux inventory
  • Log report
  • Permission review
  • Service inventory
  • Evidence helper

40 Bash for Cybersecurity Review Questions

Section titled “40 Bash for Cybersecurity Review Questions”
  1. What is Bash?
  2. Why is Bash useful for cybersecurity?
  3. What does whoami show?
  4. What does id show?
  5. What does pwd show?
  6. What does ls -la provide?
  7. What do Linux read, write, and execute permissions mean?
  8. What does chmod do?
  9. What is standard output?
  10. What is standard error?
  11. What does > do?
  12. What does >> do?
  13. What is a pipe?
  14. What does grep do?
  15. What does cut do?
  16. Why are sort and uniq often used together?
  17. What is awk useful for?
  18. What is sed used for?
  19. What does tail -f do?
  20. What is command substitution?
  21. What is an environment variable?
  22. Why is PATH security-sensitive?
  23. What is a shebang?
  24. What does set -u do?
  25. What is an exit code?
  26. What does $? represent?
  27. What are positional arguments?
  28. Why should script arguments be validated?
  29. What does ps aux show?
  30. What does systemctl manage?
  31. What does journalctl provide?
  32. What does ss show?
  33. Why are file hashes useful?
  34. What does mktemp help with?
  35. What does trap help automate?
  36. Why should variables normally be quoted?
  37. Why can eval be dangerous?
  38. Why should Bash scripts use least privilege?
  39. When should you consider replacing Bash with Python?
  40. What makes a Bash security workflow repeatable?

Remember:

LINUX SECURITY DATA
COMMAND
PIPE
FILTER
TRANSFORM
COUNT / CORRELATE
REPORT

For scripting:

INPUT
VALIDATE
PROCESS
DECISION
OUTPUT
LOG
CLEANUP

Do not think:

I NEED TO MEMORIZE
EVERY LINUX COMMAND

Think:

WHAT INFORMATION
DO I NEED?
WHICH COMMAND
PRODUCES IT?
HOW DO I FILTER
THE OUTPUT?
HOW DO I TURN IT
INTO A SECURITY RESULT?

For example:

AUTHENTICATION LOG
grep / awk
FAILED EVENTS
sort / uniq
EVENT COUNTS
SECURITY REVIEW

or:

LINUX HOST
PROCESSES
+
SERVICES
+
PORTS
+
PERMISSIONS
SECURITY INVENTORY

That is the real power of Bash for cybersecurity:

SMALL COMMANDS
+
SHELL LOGIC
+
SECURITY CONTEXT
=
POWERFUL AUTOMATION

➡️ 03 — PowerShell for Cybersecurity

The next module moves from Linux security automation into the Windows and Microsoft ecosystem.

You will learn:

POWERSHELL SHELL
CMDLETS
OBJECTS
PIPELINE
VARIABLES
CONDITIONS
LOOPS
FUNCTIONS
FILES
PROCESSES
SERVICES
WINDOWS USERS
LOCAL GROUPS
EVENT LOGS
REGISTRY
ACTIVE DIRECTORY
SECURITY AUTOMATION

The goal will be to use PowerShell as a practical tool for Windows security administration, Active Directory assessment, SOC operations, incident response, evidence collection, configuration review, and Microsoft-focused security automation.