Skip to main content

Day 4 - Linux & Shell Scripting basics

Published 3 min readMarkdown
Part of seriesDevOps

🔵 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

  1. Free / Open-source

    • No licensing cost
  2. Secure

    • No need for antivirus in most cases
  3. Fast & Lightweight

    • Ideal for production workloads
  4. Stable

    • Rarely crashes
  5. 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

  1. Device Management

  2. Memory Management

  3. Process Management

  4. 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

CommandMeaning
pwdShow current directory
lsList files/folders
ls -ltrList with details
cd foldernameEnter 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)

PurposeCommand
Show pathpwd
List filesls
Detailed listls -ltr
Change directorycd
Create filetouch
Create foldermkdir
Remove filerm
Remove folderrm -r
Open filevi
Print filecat
CPU countnproc
Memoryfree -m
Diskdf -h
Process monitoringtop

🔵 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

About the author

  • Hi there! I'm Dinesh, a passionate Cloud and DevOps enthusiast. I love to dive into the latest new technologies and sharing my journey through blog.

No comments yet. Be the first to comment.

More from this blog