ClouDIY: Bootstrapping Linux Servers – Part 2
ClouDIY: Bootstrapping Linux Servers – Part 2 Advanced tools and services for Linux system administration (based on RH134) 1. Shell Scripting Basics Shell scripts allow you to automate tasks such as backups, user setup, or software installation. They're simply text files containing a sequence of shell commands. #!/bin/bash echo "Welcome" whoami Explanation: The first line tells Linux to use the Bash shell. echo displays text, and whoami prints the current user. Tip: To run the script, first make it executable: chmod +x script.sh ./script.sh Loops and Conditions Scripts often need to make decisions or repeat actions. You can do this using if statements and loops . If statement: Checks if a file exists before taking action: if [ -f "/etc/passwd" ]; then echo "File exists" fi For loop: Repeats a command for each item in a list: for i in 1 2 3 do echo $i done This loop prints the numbers 1 to 3, one per line. grep, awk,...