Skip to main content

Command Palette

Search for a command to run...

#11 Linux - Networking - Shell Scripting

Updated
•6 min read•View as Markdown
#11  Linux - Networking - Shell Scripting
P

"Passionate DevOps enthusiast, automating workflows and optimizing infrastructure for a more efficient, scalable future."

🌱 Reflection — From Shell Scripts to Self-Belief

The past few days have been nothing short of transformative.
From learning the basics of shell scripting to realizing —
“Hey, this actually makes sense… I can do this.”

It started with curiosity and a bit of confusion, but with each command typed, each concept revisited — especially while practicing Linux and revising networking fundamentals — I began to see how far I’ve come from where I once was.

There’s still a long way to go, but looking back, it feels good to acknowledge the progress — the small wins, the growing clarity, and the confidence that builds quietly through consistent learning.

If there’s one thing I’ve truly enjoyed in this journey, it’s learning itself — the process, the patience, and the feeling of slowly mastering what once felt impossible.

🐧 Mastering Linux: From Basics to Power User — A Complete Practical Guide

“Once you understand Linux, you understand how computers truly work.”
— Anonymous

Linux isn’t just an operating system — it’s a universe of control, freedom, and automation. Whether you’re a DevOps engineer, developer, or cloud enthusiast, mastering Linux is non-negotiable.
In this guide, I’ll take you through everything — from Linux architecture, user management, and process control, to system monitoring, file permissions, and storage management — all simplified and practical.


🧩 What is Linux?

Linux is an open-source operating system that acts as a bridge between your hardware and software. It is free, customizable, and powers everything from personal computers to servers, mobile phones, and even satellites.

🧱 Core Components of a Linux System

Key Layers:

  • Hardware: The physical layer (CPU, RAM, Disks, etc.)

  • Kernel: The brain — manages processes, memory, devices, and filesystems.

  • Shell: The interpreter between user and kernel (e.g., Bash).

  • User Applications: Everything from browsers to Docker.


Linux comes in many flavors called distributions (distros) — each optimized for a purpose.

DistroUse Case
UbuntuBeginner-friendly, personal use, servers
DebianStable and reliable base system
FedoraDeveloper-focused with new features
Arch LinuxMinimal, for advanced users
Kali LinuxCybersecurity and penetration testing
Alpine LinuxLightweight for containers
Rocky/AlmaLinuxEnterprise-grade replacements for CentOS

⚙️ Setting up Linux on Windows or macOS

You don’t need a dedicated machine to explore Linux. You can use:

  • Cloud VMs (AWS EC2, Azure, GCP)

  • WSL2 (Windows Subsystem for Linux)

  • VirtualBox / VMware

  • Docker Containers ✅ (lightweight and preferred)

Run Ubuntu in Docker

docker run -dit \
  --name ubuntu-container \
  --hostname ubuntu-dev \
  --restart unless-stopped \
  --cpus="2" \
  --memory="4g" \
  --mount type=bind,source=~/docker/data,target=/data \
  ubuntu:latest /bin/bash

🧠 Pro Tip:
Avoid mounting directories from /tmp on macOS — they get deleted automatically.
Use ~/docker/data for persistent mounts.


🏗️ Understanding Linux Folder Structure

DirectoryDescription
/Root of everything
/homeUser directories
/etcConfiguration files
/usrInstalled applications
/varLogs and variable data
/tmpTemporary files (cleared on reboot)
/procVirtual process information
/sysKernel and device data
/devDevice files
/mnt, /mediaMount points for external drives

👤 User Management in Linux

Linux is a multi-user system. Every user, group, and privilege is managed carefully for security.

Create a User

useradd -m -s /bin/bash username
passwd username

Add to Sudoers

usermod -aG sudo username  # Debian-based
usermod -aG wheel username # RHEL-based

Delete a User

userdel -r username

Manage Groups

groupadd devops
usermod -aG devops piyush
groups piyush

📁 File Management Commands

TaskCommand
List filesls -l
Change directorycd /path
Create foldermkdir foldername
Remove file/folderrm file.txt, rm -r folder/
Copy/move filescp, mv
View file contentcat, less, head, tail

✍️ VI Editor — The Power of Text Editing

  • i → insert mode

  • Esc → normal mode

  • :wq → save and quit

  • dd → delete line

  • yy → copy line

  • p → paste

🚀 Mastering vi is like unlocking the true power of Linux.


🔐 File Permissions & Ownership

Each file has three access levels — user, group, others.

PermissionSymbolNumeric
Readr4
Writew2
Executex1

Change Permissions

chmod 755 script.sh

Change Ownership

chown piyush:devops script.sh

Special Permissions

  • SetUID (chmod u+s) → Run as file owner

  • SetGID (chmod g+s) → Inherit group

  • Sticky Bit (chmod +t) → Only owner can delete (used in /tmp)


⚡ Process Management

Everything running in Linux is a process.

CommandDescription
ps auxList all processes
top / htopMonitor processes interactively
kill PIDStop a process
bg, fg, jobsManage background processes
systemctl start nginxStart a service
systemctl enable sshdAuto-start at boot

🔄 Each process has a PID and a parent process — forming a process tree.


📊 System Monitoring

ResourceCommandExample
CPU & Memorytop, htop, vmstatvmstat 1 5
Memoryfree -mCheck RAM usage
Disk Usagedf -h, du -sh /var/logSpace usage
Networkip a, ping, ss -tulnpConnectivity
Logsjournalctl -f, tail -f /var/log/syslogReal-time logs

💾 Disk & Storage Management

TaskCommand
View diskslsblk, fdisk -l
Create partitionfdisk /dev/sdb
Formatmkfs.ext4 /dev/sdb1
Mountmount /dev/sdb1 /mnt
LVMpvcreate, vgcreate, lvcreate
Swap spacemkswap, swapon, swapoff

💡 For permanent mounts, add entries to /etc/fstab.


🧠 Key Takeaways

  • Linux is layered, modular, and powerful.

  • Avoid temporary paths like /tmp for long-term storage.

  • Always check permissions (ls -l) before executing scripts.

  • Use systemctl, ps, and top to keep your system under control.

  • Learn once, apply everywhere — whether it’s Docker, AWS EC2, or Kubernetes, Linux is the foundation.


🚀 Final Thought

Learning Linux is not about memorizing commands — it’s about understanding how the system thinks. Once you do, you’ll never feel locked out of any system again.

“With great terminal power, comes great system responsibility.” 🖥️


📚 If you found this helpful:

  • Follow my journey on Hashnode

  • Connect with me on LinkedIn

  • Share this post with someone learning DevOps or Cloud 🚀

More from this blog

2

20Lakh Job Hunt Journal

18 posts

“20 Lakh Job Hunt Journal isn’t for attention — it’s my mirror. A reminder to reflect on growth, hard work, and above all, consistency. A record of the discipline and belief behind my success.”