Author: Trix Cyrus
Waymap Pentesting tool: Click Here
TrixSec Github: Click Here
Basic Commands for Bash Scripting
#!/bin/bash – Shebang to specify the script interpreter.
echo – Output text to the terminal.
read – Read input from the user.
if – Conditional statement to perform logic.
else – Alternative to if condition.
fi – End of an if block.
for – Loop to iterate over a list of items.
while – Loop until a condition is true.
do – Start a loop body.
done – End a loop.
case – Conditional to match patterns.
esac – End of a case block.
exit – Exit the script or loop.
rm – Remove files or directories in scripts.
chmod +x – Make a script executable.
sleep – Pause script execution for a specified time.
clear – Clear the terminal screen.
date – Display the current date and time.
pwd – Print the working directory.
Intermediate Bash Script Commands
grep – Search for text patterns.
find – Locate files or directories.
awk – Pattern scanning and processing.
sed – Stream editor for filtering and transforming text.
cut – Remove sections from lines of text.
tr – Translate or delete characters.
df – Show disk usage in the script.
du – Display file space usage.
basename – Strip directory and suffix from filenames.
dirname – Extract directory path from a filename.
eval – Execute a string as a command.
trap – Catch signals and run cleanup code.
function – Define a function in Bash scripts.
$? – Check the exit status of the last command.
> – Redirect output to a file.
>> – Append output to a file.
2> – Redirect error output to a file.
&> – Redirect both standard and error output to a file.
source – Execute commands from a file within the current shell.
xargs – Build and execute commands from standard input.
Advanced Bash Script Commands
declare – Declare variables with specific attributes.
set – Change shell options and positional parameters.
getopts – Parse options in a script.
expr – Evaluate expressions.
let – Evaluate arithmetic expressions.
Advanced arithmetic evaluation.
crontab – Schedule scripts to run at specific intervals.
rsync – Synchronize files between locations.
scp – Securely copy files over SSH within scripts.
ssh – Run remote commands via SSH in scripts.
~Trixsec