Week 2 Done! πŸš€ My DevOps Learning Journey 🎯

Β·

3 min read

This week, I deep-dived into Shell Scripting for DevOps, exploring how to automate repetitive tasks, manage cloud resources, and interact with APIs using Linux commands. Learning these fundamentals has given me a better understanding of how scripting enhances efficiency in DevOps workflows. πŸ’»βš‘

πŸ” Key Takeaways (Commands & Their Purpose)

βœ… File Management & Navigation:

  • touch β†’ Create a file.

  • vim β†’ Open and edit files (Esc + i to insert, :wq! to save).

  • cd folder_name β†’ Navigate to a directory.

  • cat β†’ Read a file without opening it.

  • ls β†’ List files in a directory.

  • chmod β†’ Modify file permissions.

  • man β†’ Get detailed command documentation.

  • sh or ./ β†’ Execute a shell script.

  • pwd β†’ Display the current directory.

  • mkdir β†’ Create a new directory.

  • ls -ltr β†’ List files with timestamps.

  • cd .. β†’ Move back to the previous directory.

  • mv old new β†’ Rename a file or script.

βœ… System Monitoring & Process Management:

  • df β†’ Check available storage.

  • free β†’ View memory usage.

  • nproc β†’ Find out the number of CPU cores.

  • top β†’ Monitor running processes.

  • echo "text" β†’ Print a message to the terminal.

  • set -x β†’ Enable debug mode to see commands with output.

  • ps -ef β†’ List all running processes.

  • ps -ef | grep "amazon" β†’ Filter a specific process.

  • awk -F" " '{print $2}' β†’ Extract column data from text.

βœ… Piping & Filtering:

  • command | grep "info" β†’ Filter output based on a keyword.

  • set -e β†’ Exit the script if an error occurs.

  • set -o pipefail β†’ Ensure the last command in a pipeline runs successfully.

βœ… Networking & APIs:

  • curl β†’ Fetch data from external sources.

  • curl <link> | grep error β†’ Fetch logs and filter errors.

  • wget β†’ Download files and analyze them.

βœ… User Management & File Search:

  • find / -name pam.sd β†’ Locate a file.

  • sudo su - β†’ Switch to root user.

  • su username β†’ Switch to a different user.

βœ… Shell Scripting Fundamentals:

  • if-else β†’ Conditional execution.

  • for β†’ Loops for iteration.

  • trap "echo don't use the ctrl+c" SIGINT β†’ Prevent script termination on Ctrl+C.

βœ… AWS + Shell Scripting:

  • aws s3 ls β†’ List objects in an S3 bucket.

⚑ Challenges & Fixes

πŸ”Ή Issue 1: Permission Errors in Shell Scripts
Problem: Running ./script.sh resulted in a "Permission Denied" error.
Solution: Used chmod +x script.sh to make it executable.

πŸ”Ή Issue 2: AWS CLI Output Parsing
Problem: AWS CLI JSON output was difficult to read.
Solution: Used jq for better formatting:

shCopyEditaws ec2 describe-instances | jq '.'

πŸš€ Next Steps: Diving deeper into advanced scripting, Git, and GitHub automation!

πŸ’‘ Have you encountered similar issues in shell scripting? Let’s discuss in the comments! πŸ‘‡

#DevOps #ShellScripting #AWS #GitHub #Automation #Linux #DevOpsJourney

Β