Linux Administration, AWS AMI, and Shell Scripting Basics for Beginners ๐

Linux and AWS are among the most important technologies in the DevOps world. Understanding concepts like Amazon Machine Images (AMI), EBS Volumes, Nginx deployment, and Shell Scripting can help beginners build a strong foundation in Linux Administration and Cloud Computing.
In this article, we'll explore these concepts step by step with practical examples.
๐ What is AMI (Amazon Machine Image)?
An Amazon Machine Image (AMI) is a pre-configured template that contains:
Operating System
Application Server
Installed Software
Configurations
AMI allows us to create multiple EC2 instances with the same configuration whenever required.
Why Use AMI?
Faster server deployment
Backup of configured instances
Easy scaling
Consistent environments
๐ Creating an AMI from an EC2 Instance
Suppose you have already launched an EC2 instance and deployed a website.
Step 1: Launch an EC2 Instance
Create an EC2 instance using Ubuntu or Amazon Linux.
Step 2: Attach an EBS Volume
Attach a 20GB EBS Volume to the instance.
Verify attached storage:
lsblk
Check mounted filesystems:
df -h
Step 3: Install Nginx
Update packages:
sudo apt update
Install Nginx:
sudo apt install nginx -y
Check Nginx status:
sudo systemctl status nginx
Enable Nginx:
sudo systemctl enable nginx
Step 4: Deploy a Web Page
Navigate to:
cd /var/www/html
Create or modify:
sudo nano index.html
Add sample HTML content and save.
Step 5: Configure Security Group
Allow HTTP traffic.
Inbound Rule
| Type | Port | Source |
|---|---|---|
| HTTP | 80 | Anywhere (0.0.0.0/0) |
Save the rules.
Step 6: Verify Website
Copy the Public IP of the EC2 instance.
Open browser:
http://<public-ip>
You should see the Nginx webpage.
๐ผ๏ธ Creating an AMI
After configuring the server:
Steps:
Select EC2 Instance
Click Actions
Select Image and Templates
Click Create Image
Enter Image Name
Add additional volume if required
Click Create Image

AWS will take some time to generate the AMI.
๐ Launching a New Instance from AMI
Open AMIs
Select your created AMI
Click Launch Instance
Choose Key Pair
Configure instance details
Launch

The new instance will have:
Nginx installed
Website deployed
Attached configurations preserved
This is useful for backup and scaling purposes.
๐ Introduction to Shell Scripting
Shell scripting automates repetitive Linux tasks.
A shell script is a text file containing Linux commands.
Create Script
touch user.sh
Edit:
nano user.sh
Structure of a Shell Script
#!/bin/bash
echo "Hello World"
Give Execute Permission
chmod 777 user.sh
Run:
./user.sh
๐ค Creating a User Using Shell Script
#!/bin/bash
read -p "Enter Username: " name
sudo useradd -m $name
echo "User Created Successfully"
๐ Creating Files and Folders Using User Input
#!/bin/bash
read -p "Enter file name: " file
touch $file
Folder Creation
#!/bin/bash
read -p "Enter folder name: " folder
mkdir $folder
๐ Creating Folder and Assigning Permissions
#!/bin/bash
read -p "Enter folder name: " folder
mkdir $folder
chmod 777 $folder
echo "Folder Created Successfully"
Permission Meaning
| Value | Permission |
|---|---|
| 7 | Read + Write + Execute |
| 6 | Read + Write |
| 5 | Read + Execute |
| 4 | Read Only |
๐ Conditional Statements in Shell Scripting
Conditional statements allow decision-making.
Example
#!/bin/bash
read -p "Enter Name: " name
read -p "Enter Percentage: " per
if [[ $name == "linux" ]]
then
echo "Approved"
elif [[ $per -ge 100 ]]
then
echo "Accepted"
else
echo "Rejected"
fi
๐ Grade Calculator Using If-Else
#!/bin/bash
read -p "Enter Marks: " mark
if [[ $mark -ge 90 ]]
then
echo "Grade A"
elif [[ $mark -ge 80 ]]
then
echo "Grade B"
elif [[ $mark -ge 70 ]]
then
echo "Grade C"
else
echo "Grade D"
fi
Sample Output
Enter Marks: 85
Grade B
โ๏ธ Using Functions in Shell Script
Functions improve code reusability.
Example
#!/bin/bash
user_validation() {
read -p "Enter Name: " name
read -p "Enter Percentage: " per
if [[ $name == "linux" ]]
then
echo "Approved"
elif [[ $per -ge 100 ]]
then
echo "Accepted"
else
echo "Rejected"
fi
}
user_validation
๐ฏ Conclusion
Learning Linux Administration and AWS basics is a great starting point for a DevOps career. In this article, we covered:
โ AMI Creation and Usage โ EBS Volume Attachment and Mounting โ Unmounting Volumes Safely โ Nginx Installation and Deployment โ Security Group Configuration โ Shell Scripting Basics โ User Creation Automation โ File and Folder Management โ Conditional Statements โ Functions in Shell Scripts
Mastering these fundamentals will help you automate tasks, manage cloud infrastructure, and build scalable environments efficiently.
Happy Learning! ๐๐งโ๏ธ



