DEV Community

Prince Malik
Prince Malik

Posted on

1

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

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:

  1. - touch β†’ Create a file.
  2. - vim β†’ Open and edit files (Esc + i to insert, :wq! to save).
  3. - cd folder_name β†’ Navigate to a directory.
  4. - cat β†’ Read a file without opening it.
  5. - ls β†’ List files in a directory.
  6. - chmod β†’ Modify file permissions.
  7. - man β†’ Get detailed command documentation.
  8. - sh or ./ β†’ Execute a shell script.
  9. - pwd β†’ Display the current directory.
  10. - mkdir β†’ Create a new directory.
  11. - ls -ltr β†’ List files with timestamps.
  12. - cd .. β†’ Move back to the previous directory.
  13. - mv old new β†’ Rename a file or script.

βœ… System Monitoring & Process Management:

  1. df β†’ Check available storage.
  2. free β†’ View memory usage.
  3. nproc β†’ Find out the number of CPU cores.
  4. top β†’ Monitor running processes.
  5. echo "text" β†’ Print a message to the terminal.
  6. set -x β†’ Enable debug mode to see commands with output.
  7. ps -ef β†’ List all running processes.
  8. ps -ef | grep "amazon" β†’ Filter a specific process.
  9. awk -F" " '{print $2}' β†’ Extract column data from text.

βœ… Piping & Filtering:

  1. command | grep "info" β†’ Filter output based on a keyword.
  2. set -e β†’ Exit the script if an error occurs.
  3. set -o pipefail β†’ Ensure the last command in a pipeline runs successfully.

βœ… Networking & APIs:

  1. curl β†’ Fetch data from external sources.
  2. curl | grep error β†’ Fetch logs and filter errors.
  3. wget β†’ Download files and analyze them.

βœ… User Management & File Search:

  1. find / -name pam.sd β†’ Locate a file.
  2. sudo su - β†’ Switch to root user.
  3. su username β†’ Switch to a different user.

βœ… Shell Scripting Fundamentals:

  1. if-else β†’ Conditional execution.
  2. for β†’ Loops for iteration.
  3. trap "echo don't use the ctrl+c" SIGINT β†’ Prevent script termination on Ctrl+C.

βœ… AWS + Shell Scripting:

  1. 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:

Command - shCopyEditaws ec2 describe-instances | jq '.'

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

πŸ“Œ Follow my journey on:
πŸ”Ή LinkedIn: https://www.linkedin.com/in/princemalikk
πŸ”Ή Dev.to: https://dev.to/princemalikk
πŸ”Ή GitHub: https://github.com/Princemalikk
πŸ”Ή Hashnode: https://princemalikk.hashnode.dev

Sentry image

Make it make sense

Only get the information you need to fix your code that’s broken with Sentry.

Start debugging β†’

Top comments (0)

πŸ‘‹ Kindness is contagious

Explore this compelling article, highly praised by the collaborative DEV Community. All developers, whether just starting out or already experienced, are invited to share insights and grow our collective expertise.

A quick β€œthank you” can lift someone’s spiritsβ€”drop your kudos in the comments!

On DEV, sharing experiences sparks innovation and strengthens our connections. If this post resonated with you, a brief note of appreciation goes a long way.

Get Started