Skip to main content

Command Palette

Search for a command to run...

πŸ“˜ DevOps Week 2 – Linux OS Fundamentals & Shell Scripting

Learn Linux commands, shell scripting fundamentals, and build a real-world AWS Resource Tracker project to automate monitoring and optimize cloud costs.

Updated
β€’16 min read
πŸ“˜ DevOps Week 2 – Linux OS Fundamentals & Shell Scripting
H
πŸ‘‹ Hi, I’m Hritik Ranjan β€” a B.Tech CSE student and a passionate tech enthusiast focused on Quality Engineering, AI/ML, Cybersecurity, and DevOps. πŸ’‘ I enjoy building and testing scalable, secure, and intelligent systems that solve real-world problems. My expertise and interests include: πŸ”Ή Quality Assurance & Testing Hands-on experience in manual and automation testing using Selenium & Java, ensuring high-quality and reliable applications. πŸ”Ή Artificial Intelligence & Machine Learning Exploring advanced algorithms and developing intelligent systems for practical use cases. πŸ”Ή Cybersecurity Focused on vulnerability assessment, security testing, and system hardening. πŸ”Ή Web Development Building responsive and user-friendly applications using modern technologies. πŸ”Ή Data Science Analyzing complex data to extract actionable insights. πŸ’Ό Key Projects: πŸš€ Blindness Detection System Applied computer vision techniques to detect blindness-related conditions. πŸš€ AI-Powered Rail Madad Enhancement Developed an intelligent complaint management system to improve railway customer service. πŸš€ Interactive Applications Built multiple projects like quiz apps, calculators, and productivity tools. 🌱 I’m continuously learning and improving my skills in DevOps, Cloud, and Automation to become a well-rounded engineer. 🀝 Open to collaborations, internships, and opportunities in QA, DevOps, AI/ML, and Cybersecurity. πŸ“« Let’s connect: hritikranjan1408@gmail.com

πŸ”Ή 1. What is an Operating System (OS)?

  • OS = Interface between Hardware & Software

πŸ‘‰ It acts as a bridge:

  • Hardware (CPU, RAM, Disk)

  • Software (Applications, Programs)


🎯 Functions of OS:

  • Process management

  • Memory management

  • File system management

  • Device control

πŸ‘‰ Example OS:

  • Linux

  • Windows

  • macOS


πŸ”Ή 2. What is Linux?

  • Linux = Open-source Operating System

  • Widely used in:

    • Servers

    • Cloud (AWS, Azure)

    • DevOps


βœ” Why Linux is Important

  • Free & open source

  • Secure

  • Lightweight

  • Most servers run on Linux


πŸ”Ή 3. Linux Architecture (Basic Idea)

User β†’ Shell β†’ Kernel β†’ Hardware

βœ” Components:

  • Kernel β†’ Core of OS (controls hardware)

  • Shell β†’ Interface to interact with system

  • File System β†’ Organizes data


πŸ”Ή 4. What is Shell?

  • Shell = Command Line Interface (CLI)

πŸ‘‰ It allows:

  • Running commands

  • Managing files

  • Executing scripts


βœ” Types of Shell:

  • Bash (most common)

  • Sh

  • Zsh


πŸ“˜ Linux & Shell Scripting


πŸ”Ή 1. Introduction

  • This video teaches:

    • Basic Linux commands

    • File handling

    • Shell scripting basics

    • Automation concepts

πŸ‘‰ Focus: Learn Linux + start scripting


πŸ”Ή 2. Purpose of Scripting & Automation

  • Instead of doing tasks manually:
    πŸ‘‰ Use scripts to automate

βœ” Example:

  • Backup files

  • Run multiple commands at once

πŸ‘‰ Benefit:

  • Saves time

  • Reduces errors


πŸ”Ή 3. How to Create a File?

touch file.txt

πŸ‘‰ Creates empty file


πŸ”Ή 4. List Files & Folders

ls

πŸ‘‰ Shows all files


πŸ”Ή 5. man Command

man ls

πŸ‘‰ Shows manual/help of command


πŸ”Ή 6. vi / vim Editor (Write File)

vim file.txt

πŸ‘‰ Used to:

  • Create file

  • Edit file


Modes in vim:

  • Insert mode β†’ write text

  • Command mode β†’ run commands


πŸ”Ή 7. Difference: touch vs vim

touch vim
Creates file only Create + edit file
No content Can write content

πŸ”Ή 8. Copy Content in Linux

cp file1 file2

πŸ‘‰ Copy file


πŸ”Ή 9. #!/bin/bash or #!/bin/sh

  • Called Shebang

πŸ‘‰ Purpose:

  • Tells system: πŸ‘‰ Which shell to use to run script

πŸ”Ή 10. Difference: bash, ksh, dash

Shell Use
bash Most common
ksh Advanced scripting
dash Lightweight & fast

πŸ”Ή 11. Insert Command (vim)

  • Press i β†’ enter insert mode

  • Start writing


πŸ”Ή 12. echo Command

echo "Hello"

πŸ‘‰ Print output


πŸ”Ή 13. Execute Shell Script

./script.sh

πŸ”Ή 14. Grant Permissions

chmod +x script.sh

πŸ‘‰ Makes script executable


πŸ”Ή 15. chmod Command

chmod 777 file.txt

πŸ‘‰ Change file permissions


Permission Types:

  • r = read

  • w = write

  • x = execute


πŸ”Ή 16. Check Command History

history

πŸ‘‰ Shows previously used commands


πŸ”Ή 17. Create Folder

mkdir foldername

πŸ”Ή 18. Change Directory

cd foldername

πŸ”Ή 19. Simple Shell Script

#!/bin/bash
echo "Hello World"

πŸ”Ή 20. Purpose of Shell Scripting in DevOps

  • Automate tasks

  • Deploy applications

  • Run pipelines

πŸ‘‰ Very important in DevOps


πŸ”Ή 21. Check CPU & RAM

free -h

πŸ‘‰ Shows RAM


lscpu

πŸ‘‰ Shows CPU info


πŸ”Ή 22. Top Command

top

πŸ‘‰ Shows:

  • Running processes

  • CPU usage

  • Memory usage


πŸ“˜ Node Health, Debugging, Pipes, AWK, Advanced Scripting


πŸ”Ή 1. DevOps Use Case: Node Health Check

πŸ‘‰ Goal: Check if a server (node) is healthy or not

βœ” What to check:

  • CPU usage

  • Memory (RAM)

  • Disk space

  • Running processes


πŸ”Ή 2. Sample Node Health Script (Basic Idea)

#!/bin/bash
echo "Checking system health..."
top
free -h
df -h

πŸ‘‰ This script checks:

  • CPU β†’ top

  • RAM β†’ free -h

  • Disk β†’ df -h


πŸ”Ή 3. Good Practices in Scripting

  • Use clear variable names

  • Add comments

  • Use echo statements

  • Handle errors properly

πŸ‘‰ Makes script readable & professional


πŸ”Ή 4. Improve Script Readability

echo "Checking CPU usage..."
echo "Checking Memory..."

πŸ‘‰ Helps understand output clearly


πŸ”Ή 5. Debug Mode

set -x

πŸ‘‰ Shows:

  • Each command before execution

πŸ‘‰ Used for debugging


πŸ”Ή 6. What are Processes?

  • Process = Running program

βœ” List Processes:

ps

βœ” Find Process ID:

ps -ef

πŸ”Ή 7. grep & Pipe (|) – VERY IMPORTANT πŸ”₯

βœ” Pipe:

  • Pass output of one command β†’ another
ps -ef | grep nginx

πŸ‘‰ Find specific process


🎯 Interview Point:

πŸ‘‰ Pipe = connects multiple commands


πŸ”Ή 8. AWK Command

  • Used for:

    • Filtering

    • Extracting specific columns

ps -ef | awk '{print $2}'

πŸ‘‰ Prints process ID


πŸ”Ή 9. set -e (Error Handling)

set -e

πŸ‘‰ Script stops if error occurs


πŸ”Ή 10. set -o pipefail

set -o pipefail

πŸ‘‰ If any command in pipeline fails β†’ script fails

πŸ‘‰ Important for production scripts


πŸ”Ή 11. DevOps Use Case: Search Errors in Logs

grep "error" logfile.txt

πŸ‘‰ Used to:

  • Debug issues

  • Find failures


πŸ”Ή 12. wget Command

wget <url>

πŸ‘‰ Download files from internet


πŸ”Ή 13. CURL vs WGET

CURL WGET
API calls File download
More flexible Simple download

πŸ”Ή 14. find Command

find . -name "file.txt"

πŸ‘‰ Search files


πŸ”Ή 15. sudo vs su

Command Use
sudo Run as admin
su Switch user

πŸ”Ή 16. If-Else in Shell

if [ \(a -gt \)b ]
then
 echo "A is greater"
else
 echo "B is greater"
fi

πŸ”Ή 17. For Loop

for i in 1 2 3
do
 echo $i
done

πŸ“˜AWS Resource Tracker Project


πŸ”Ή 1. Project Goal

πŸ‘‰ Build script to:

  • Track AWS resources

  • Reduce cost


βœ” Why Important?

Cloud = Pay-as-you-go

  • Unused resources = Money waste

πŸ‘‰ Example:

  • Unused EC2

  • Orphaned EBS


πŸ”Ή 2. Tools Used

  • AWS CLI

  • Bash scripting

  • Cron jobs


πŸ”Ή 3. Resource Tracking Commands

βœ” S3 Buckets:

aws s3 ls

βœ” EC2 Instances:

aws ec2 describe-instances

βœ” Lambda:

aws lambda list-functions

βœ” IAM Users:

aws iam list-users

πŸ”Ή 4. Debug Mode

set -x

πŸ‘‰ Used to debug script


πŸ”Ή 5. JSON Parsing using JQ

jq '.Reservations[].Instances[].InstanceId'

πŸ‘‰ Extract specific data from JSON


πŸ”Ή 6. Automation using Cron Job

crontab -e

πŸ‘‰ Schedule script

βœ” Example:

0 9 * * * /home/script.sh

πŸ‘‰ Runs daily at 9 AM


πŸ”Ή 7. Full Workflow

  1. Write script

  2. Fetch AWS data

  3. Filter using JQ

  4. Generate report

  5. Automate using cron


πŸ”Ή 8. Real DevOps Use Case

πŸ‘‰ Companies use this to:

  • Track unused resources

  • Save cost

  • Monitor infrastructure


Project link - https://github.com/hritikranjan1/shell-scripting-projects.git


πŸ“˜ Git, GitHub, Branching & GitHub API (Simple Flow)


πŸ”Ή 1. Problem Statement (Real DevOps Scenario)

As a DevOps Engineer πŸ‘‡

  • You manage multiple repositories

  • Many users have access

πŸ‘‰ Problem:

  • Checking access manually from GitHub UI is slow & inefficient

  • Especially during employee offboarding

πŸ‘‰ Solution:

  • Use GitHub API + Automation Script

πŸ”Ή 2. API vs CLI (Important Concept)

βœ” CLI (Command Line Interface)

  • Direct commands in terminal πŸ‘‰ Example:
kubectl get pods

βœ” API (Application Programming Interface)

  • Communicate with apps using:

    • HTTP requests

    • JSON data

πŸ‘‰ Example:

curl https://api.github.com/repos

🎯 Difference:

CLI API
Easy to use More flexible
Limited control Full control
Manual usage Automation friendly

πŸ”Ή 3. GitHub API Integration (Main Concept)

πŸ‘‰ GitHub provides APIs to:

  • Get repo details

  • List users

  • Check PRs & issues


βœ” How it works:

  1. Send request using curl

  2. Get response in JSON

  3. Filter using jq


πŸ“Œ Example:

curl https://api.github.com/repos/user/repo

βœ” Parsing Data:

jq '.[] | .login'

πŸ‘‰ Extract useful data from JSON


πŸ”Ή 4. Script Flow (Project)

πŸ‘‰ Steps used in video:

  1. Clone script

  2. Add GitHub token (for authentication)

  3. Run script

  4. Fetch repo data

  5. Filter users

  6. Show authorized users


βœ” Tools Used:

  • curl

  • jq

  • Bash scripting


βœ” Improvement Tips:

  • Use functions

  • Add comments

  • Handle errors


πŸ”Ή 5. Introduction to Version Control (VCS)

πŸ‘‰ VCS = Track changes in code


βœ” Why we need VCS?

  • Multiple developers work together

  • Track changes/history

  • Go back to old version


πŸ”Ή 6. Types of Version Control

βœ” Centralized (Old)

  • Example: SVN

  • One central server

πŸ‘‰ Problem:

  • If server down β†’ work stops

βœ” Distributed (Git)

  • Each user has full copy

πŸ‘‰ Benefit:

  • Work even offline

πŸ”Ή 7. Git vs GitHub

Git GitHub
Tool Platform
Local system Cloud
Version control Collaboration

πŸ”Ή 8. Git Basic Workflow (Very Important πŸ”₯)

πŸ‘‰ Git lifecycle:

Working Directory β†’ Staging β†’ Repository

βœ” Commands:

1. Initialize repo

git init

2. Check status

git status

3. Add files

git add .

4. Commit changes

git commit -m "message"

5. View history

git log

6. See changes

git diff

πŸ”Ή 9. Push Code to GitHub

git push

πŸ‘‰ Upload local code to GitHub


πŸ”Ή 10. Clone vs Fork

βœ” Clone:

git clone <repo-url>

πŸ‘‰ Download repo locally


βœ” Fork:

πŸ‘‰ Copy repo on GitHub

πŸ‘‰ Used for:

  • Open-source contribution

πŸ”Ή 11. Branching Concept (VERY IMPORTANT πŸ”₯)

βœ” Why Branching?

  • Work on new feature safely

  • Don’t break main code


βœ” Main Branch:

  • main / master πŸ‘‰ Production-ready code

βœ” Other Branches:

  • Feature Branch β†’ New feature

  • Release Branch β†’ Prepare release

  • Hotfix Branch β†’ Fix urgent bug


πŸ”Ή 12. Branch Workflow

πŸ‘‰ Steps:

  1. Create branch

  2. Work on feature

  3. Test code

  4. Merge to main


πŸ”Ή 13. Merge Strategies


βœ” Git Merge

  • Combine branches

  • Keeps history


βœ” Git Rebase

  • Clean linear history

πŸ‘‰ Preferred in large projects


βœ” Git Cherry-pick

  • Copy specific commit

πŸ”Ή 14. Git Lifecycle (Full Flow)

git init β†’ git add β†’ git commit β†’ git push

πŸ”Ή 15. Important Git Commands

  • git pull β†’ Get latest code

  • git remote β†’ Manage repo link

  • git branch β†’ Show branches


πŸ”Ή 16. Real DevOps Workflow

  1. Developer writes code

  2. Create feature branch

  3. Commit changes

  4. Push to GitHub

  5. Create PR (Pull Request)

  6. Review & merge


πŸ”Ή 17. Key Takeaways

  • Git = Version control

  • GitHub = Collaboration platform

  • Branching = Safe development

  • API = Automation

  • Scripts = Save time



πŸš€ Continue Your Learning Journey

Thank you for taking the time to read this article.

Technology is evolving rapidly, and continuous learning is one of the most valuable investments you can make in your career. Whether you're exploring DevOps, Cloud Computing, Artificial Intelligence, Cybersecurity, Software Development, Data Science, or Career Growth, the resources below can help you deepen your knowledge and stay ahead in the industry.


πŸŽ“ Recommended Learning Platforms

πŸš€ Coursera

Learn from world-renowned universities and industry leaders including Google, IBM, Stanford, Microsoft, Meta, and many more.

βœ” Professional Certificates βœ” Career-focused Learning Paths βœ” AI & Machine Learning Programs βœ” Cloud & DevOps Certifications βœ” Business & Leadership Courses

πŸ”— https://imp.i384100.net/k0KvbV


πŸ’» Udemy

One of the largest online learning platforms with practical, hands-on courses covering:

βœ” DevOps & Kubernetes βœ” Docker & Cloud Computing βœ” AWS, Azure & GCP βœ” Programming & Development βœ” Cybersecurity & Ethical Hacking

πŸ”— https://trk.udemy.com/MAL2MY


πŸ“Š DataCamp

A great platform for anyone interested in:

βœ” Python Programming βœ” SQL & Databases βœ” Data Analytics βœ” Machine Learning βœ” Artificial Intelligence

Interactive learning paths and hands-on projects make it ideal for beginners and professionals alike.

πŸ”— https://datacamp.pxf.io/nX4kER


πŸŽ“ edX

Access high-quality courses and certifications from leading institutions such as:

βœ” Harvard University βœ” MIT βœ” Berkeley βœ” Microsoft

Perfect for learners seeking university-level education online.

πŸ”— https://edx.sjv.io/POvVeN


🎨 Domestika

Enhance your creative skills with courses on:

βœ” Graphic Design βœ” Video Editing βœ” Animation βœ” Digital Marketing βœ” Content Creation

πŸ”— https://domestika.sjv.io/dynKAW


πŸ› οΈ Recommended Tools & Resources

πŸ”₯ AppSumo

Discover exclusive lifetime deals on:

βœ” AI Tools βœ” Productivity Software βœ” Developer Utilities βœ” Marketing Platforms βœ” Business Applications

A must-have resource for developers, creators, freelancers, and entrepreneurs looking to save money while accessing premium tools.

πŸ”— https://appsumo.8odi.net/L04a33


πŸ›’ Shopify

Looking to start an online business or launch an eCommerce store?

Shopify provides everything you need to build, manage, and scale an online business.

βœ” Online Store Builder βœ” Payment Integration βœ” Inventory Management βœ” Marketing Tools

πŸ”— https://shopify.pxf.io/Vxv09k


🌐 WordPress, WooCommerce & Jetpack

Create professional websites, blogs, and online stores with one of the most trusted web ecosystems in the world.

Ideal for:

βœ” Personal Blogs βœ” Portfolio Websites βœ” Business Websites βœ” eCommerce Stores

πŸ”— https://automattic.pxf.io/Z6vR5W


🌍 Language Learning Resources

πŸ—£οΈ Preply

Learn English and other languages through personalized one-on-one tutoring sessions with experts from around the world.

πŸ”— https://preply.sjv.io/o4gBDY


πŸ“š British Council English Online

Improve your professional communication skills and English fluency through structured learning programs.

πŸ”— https://englishonline.sjv.io/9VOGa4


🧠 Rosetta Stone

One of the most recognized language-learning platforms for immersive language acquisition.

πŸ”— https://aff.rosettastone.com/X4OyqG


πŸ§ͺ Science & Educational Resources

πŸ”¬ MEL Science

Interactive science kits and educational experiences designed to make STEM learning engaging and practical.

πŸ”— https://imp.i328067.net/bk2beg


πŸ“– Carson Dellosa Education

Educational materials and learning resources for students, teachers, and lifelong learners.

πŸ”— https://carsondellosaeducation.sjv.io/E0JbjW


❀️ Support My Work

Creating detailed technical content, tutorials, guides, and learning resources takes significant time and effort.

If you find my articles helpful and would like to support my work, you can do so through the following platforms:

⭐ Become a GitHub Sponsor

Support my open-source contributions, technical content, and community projects.

πŸ”— https://github.com/sponsors/hritikranjan1


β˜• Buy Me a Chai

Enjoying my content? Consider buying me a chai and supporting future tutorials, guides, and educational resources.

πŸ”— https://www.chai4.me/hritikranjan


πŸ‘¨β€πŸ’» Connect With Me

Hritik Ranjan

πŸ’‘ AI Enthusiast ☁️ DevOps Learner πŸ” Cybersecurity Advocate πŸ’» Software Developer

Connect & Follow

πŸ”— GitHub: https://github.com/hritikranjan1

πŸ”— LinkedIn: https://linkedin.com/in/hritikranjan1


πŸ“’ Found This Article Helpful?

If this article added value to your learning journey:

βœ… Share it with your network
βœ… Bookmark it for future reference
βœ… Follow for more DevOps, AI, Cloud, Cybersecurity, and Software Engineering content

Thank you for reading and being part of this learning journey.

Keep Learning. Keep Building. Keep Growing. πŸš€

DevOps Learning Journey πŸš€

Part 2 of 14

Documenting my step-by-step journey of learning DevOps β€” from basics to advanced concepts. In this series, I’ll share weekly notes, hands-on practice, tools, and real-world insights as I grow in DevOps.

Up next

πŸš€ DevOps Week 3: AWS Services, Configuration Management & IaC

A complete guide covering top AWS services, Ansible fundamentals, and Infrastructure as Code (Terraform) for DevOps beginners.

More from this blog

D

DevOps Journey by Hritik

14 posts

Started my DevOps journey from scratch, covering Linux, shell scripting, and a real-world AWS project for beginners.