What is a Shell?
A shell is a command-line interpreter that lets you interact with the operating system. Think of it as a translator between you and the kernel.
Shell Scripting Concept:
Instead of typing commands one by one, you store them in a script file (.sh
) so they execute sequentially. This is automation for repetitive tasks like:
Key points in shell scripts:
#!
) – tells Linux which interpreter to use (e.g., #!/bin/bash
)if
, for
, while
loopsExample script concept:
#!/bin/bash
USER_NAME="Suhas"
echo "Welcome, $USER_NAME"
if [ $(date +%u) -gt 5 ]; then
echo "It's weekend!"
else
echo "It's a weekday."
fi
Save as myscript.sh
, then:
chmod +x myscript.sh
./myscript.sh