Day 4 - Linux & Shell Scripting basics
π΅ 1. What is an Operating System (OS)?
An Operating System is a software layer that acts as a bridge between hardware and software.
β OS Role
User runs an application (software)
Software sends request β Operating System
OS interacts with Hardware (CPU, RAM, Storage, IO)
Response travels back the same way
β Simple Definition
OS = Medium that enables communication between Hardware and Software
Without an OS, applications cannot use CPU/RAM or perform any tasks.
π΅ 2. Why Linux? Why not Windows?
Linux is the most used OS in servers & DevOps.
β Key Reasons
Free / Open-source
- No licensing cost
Secure
- No need for antivirus in most cases
Fast & Lightweight
- Ideal for production workloads
Stable
- Rarely crashes
Flexible (Many Distributions)
Ubuntu, CentOS, RedHat, Debian, Alpine, Fedoraβ¦
β Where Linux is used?
Servers
Cloud VMs
Containers
Kubernetes
DevOps Tools (Jenkins, Docker, Ansible, GitLab CIβ¦)
π΅ 3. Linux Architecture (Simple Version)
+-------------------------+
| Applications / Softwares|
+-------------------------+
| Compilers | User Process|
| System Softwares |
+-------------------------+
| System Libraries (glibc) |
+-------------------------+
| Kernel (Heart of OS) |
+-------------------------+
| Hardware (CPU | RAM | IO)|
+-------------------------+
β Kernel Responsibilities
Device Management
Memory Management
Process Management
System Calls Handling
π΅ 4. What is Shell?
Shell = Interface to talk to the Linux OS using commands.
Windows β GUI
Linux Servers β CLI (Command Line Interface)
Popular shell β Bash
Shell allows:
Creating files
Navigating directories
Managing processes
Checking CPU/RAM
Writing scripts (.sh)
π΅ 5. Basic Linux Commands
π Navigation
| Command | Meaning |
pwd | Show current directory |
ls | List files/folders |
ls -ltr | List with details |
cd foldername | Enter folder |
cd .. | Go back |
cd ../.. | Go two levels back |
π File & Folder Operations
β Create
touch file.txt # create file
mkdir folder # create directory
β Edit File (VI Editor)
vi file.txt
Inside VI:
Press i β insert mode
Type content
Press Esc
Type :wq β save & exit
β View File
cat file.txt
β Delete
rm file.txt # delete file
rm -r folder # delete folder
π΅ 6. System Monitoring Commands
β Memory
free -m
β CPU Cores
nproc
β Disk Usage
df -h
β Combined Monitoring
top
Shows:
CPU usage
Memory usage
Running processes
π΅ 7. Important Commands (Quick List)
| Purpose | Command |
| Show path | pwd |
| List files | ls |
| Detailed list | ls -ltr |
| Change directory | cd |
| Create file | touch |
| Create folder | mkdir |
| Remove file | rm |
| Remove folder | rm -r |
| Open file | vi |
| Print file | cat |
| CPU count | nproc |
| Memory | free -m |
| Disk | df -h |
| Process monitoring | top |
π΅ 8. Why Shell Scripting in DevOps?
Shell scripts are used for:
Automating deployments
Creating scheduled jobs (cron)
Server maintenance
Log monitoring
Starting/stopping services
CI/CD pipelines