DevOps Foundations: Exploring AWS, Linux, and Shell Scripting

Md Sharjil Alam - Aug 19 - - Dev Community

DevOps Essentials: Diving into AWS, Linux, and Shell Scripting

Hey Dev.to Community!

Diving into AWS, Linux, and shell scripting has been a key part of my DevOps journey. These skills are fundamental for managing and automating IT infrastructure. Let’s explore what I’ve learned and how it translates into practical usage.

Table Of Contents

Setting Up AWS Instances

Starting with AWS, I focused on creating and managing EC2 instances. Here’s a brief guide:

Launch an EC2 Instance

  1. Go to the AWS Management Console.
  2. Select EC2 and click Launch Instance.
  3. Choose an AMI (Amazon Machine Image), select an instance type, and configure details.
  4. Review and launch the instance.

Connect to Your VM

  1. Use an SSH client like MobaXterm.
  2. Connect using the command:
   ssh -i "your-key.pem" ec2-user@your-instance-ip
Enter fullscreen mode Exit fullscreen mode

Getting to Know Linux

Linux is a cornerstone of DevOps due to its security, customization, and effectiveness in managing servers. Here’s why it’s important:

  • Why Linux? It’s secure, customizable, and ideal for managing servers and automating tasks.

Must-Know Linux Commands

Here are essential Linux commands and their functions:

  • ls: Lists files and directories. Example: ls -ltr shows files sorted by modification time.
  • pwd: Prints the current working directory. Example: pwd displays the full path of the directory you’re in.
  • cd: Changes directory. Example: cd /path/to/directory navigates to the specified directory.
  • vim / vi: Edits files. Example: vim filename.txt opens a file for editing.
  • cat: Displays file contents. Example: cat filename.txt shows the content of a file.
  • mkdir: Creates a directory. Example: mkdir new_directory creates a new directory.
  • touch: Creates a new file or updates the timestamp of an existing file. Example: touch new_file.txt creates a file.
  • rm: Removes files or directories. Example: rm filename.txt deletes a file.
  • free: Shows memory usage. Example: free -h provides a summary of memory usage.
  • nproc: Displays the number of CPU cores. Example: nproc shows the number of processing units.
  • df -h: Shows disk space usage. Example: df -h displays disk usage in a readable format.
  • top: Provides real-time system performance data. Example: top shows system processes and resource usage.
  • man: Accesses command manuals. Example: man ls provides detailed information about the ls command.

Exploring Useful Tools

Here are some tools that have been game-changers:

  • grep: Searches for patterns in text. Example: ps -ef | grep amazon finds processes related to amazon.
  • awk: Processes and extracts data. Example: echo "one two three" | awk '{print $2}' prints the second word.
  • curl: Fetches data from URLs. Example: curl https://api.example.com/data retrieves data from a specified URL.
  • wget: Downloads files from the web. Example: wget https://example.com/file.zip downloads a file from a given URL.

Writing Basic Shell Scripts

Shell scripting is a powerful way to automate tasks. Here’s an example:

if-else Statements

if [ -f "file.txt" ]; then
  echo "File exists."
else
  echo "File does not exist."
fi
Enter fullscreen mode Exit fullscreen mode

Loops

for i in {1..5}; do
  echo "Number $i"
done
Enter fullscreen mode Exit fullscreen mode

Conclusion

Getting hands-on with AWS, Linux, and shell scripting has provided valuable insights into managing and automating infrastructure. These tools and commands form a solid foundation for anyone in DevOps.
Let’s Connect!
🔗 For more updates and insights
connect with me on LinkedIn!
connect with me on Twitter!

#DevOps #AWS #Linux #ShellScripting #TechBlog

. . . . . .
Terabox Video Player