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
- Getting to Know Linux
- Must-Know Linux Commands
- Exploring Useful Tools
- Writing Basic Shell Scripts
Setting Up AWS Instances
Starting with AWS, I focused on creating and managing EC2 instances. Here’s a brief guide:
Launch an EC2 Instance
- Go to the AWS Management Console.
- Select EC2 and click Launch Instance.
- Choose an AMI (Amazon Machine Image), select an instance type, and configure details.
- Review and launch the instance.
Connect to Your VM
- Use an SSH client like MobaXterm.
- Connect using the command:
ssh -i "your-key.pem" ec2-user@your-instance-ip
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 -ltrshows files sorted by modification time. -
pwd: Prints the current working directory. Example:pwddisplays the full path of the directory you’re in. -
cd: Changes directory. Example:cd /path/to/directorynavigates to the specified directory. -
vim / vi: Edits files. Example:vim filename.txtopens a file for editing. -
cat: Displays file contents. Example:cat filename.txtshows the content of a file. -
mkdir: Creates a directory. Example:mkdir new_directorycreates a new directory. -
touch: Creates a new file or updates the timestamp of an existing file. Example:touch new_file.txtcreates a file. -
rm: Removes files or directories. Example:rm filename.txtdeletes a file. -
free: Shows memory usage. Example:free -hprovides a summary of memory usage. -
nproc: Displays the number of CPU cores. Example:nprocshows the number of processing units. -
df -h: Shows disk space usage. Example:df -hdisplays disk usage in a readable format. -
top: Provides real-time system performance data. Example:topshows system processes and resource usage. -
man: Accesses command manuals. Example:man lsprovides detailed information about thelscommand.
Exploring Useful Tools
Here are some tools that have been game-changers:
-
grep: Searches for patterns in text. Example:ps -ef | grep amazonfinds 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/dataretrieves data from a specified URL. -
wget: Downloads files from the web. Example:wget https://example.com/file.zipdownloads 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
Loops
for i in {1..5}; do
echo "Number $i"
done
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
Top comments (0)