Skip to main content

Command Palette

Search for a command to run...

Day 4 - Linux & Shell Scripting basics

Updated
β€’3 min read

πŸ”΅ 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

More from this blog

Dinesh's Blog

104 posts

Day 4 - Linux & Shell Scripting basics