DEV Community

Cover image for 🐧 Linux for DevOps [Week 1]: Mastering the Essentials
Suvrajeet Banerjee
Suvrajeet Banerjee Subscriber

Posted on • Edited on

🐧 Linux for DevOps [Week 1]: Mastering the Essentials

Intro!

Hey DevOps enthusiasts! 🌟 If you're like me, diving into Week 1 of Pravin Mishra's free DevOps cohort, it literally felt like unlocking a treasure chest of practical skills. Building upon the Week 0 foundations What Fuels the Internet & Prerequisites for DevOps Cohort [Week-0]), this session was a whirlwind of Linux magic. We went from understanding why Linux reigns supreme in cloud and DevOps to deploying real apps on AWS. Pure hands-on action that had me hooked from the first command. Whether you're a beginner or brushing up, let's break it down with the key takeaways & tips. Ready to level up? Let's dive in! 💻


Linux+for+DevOps


🌐 Why Linux Dominates DevOps & Cloud Engineering

🚨 Over 80% of cloud workloads run on Linux — it's the backbone for containers, automation tools like Terraform and Ansible, and DevOps practices. As emphasized in the cohort, mastering Linux isn't optional; it's essential for troubleshooting and scaling in real-world scenarios.

🐧 Linux — what started as Linus Torvalds' hobby project in the '90s now powers 90%+ of global servers, thus becoming the engine of modern infrastructure because of it’s open-source (under GPL), stable, scalable(from RasPi to supercomputers) & ridiculously tweakable nature. If you want to own cloud, containers, or infra automation, you need to own the shell. This post mixes the cohort’s hands-on lessons with a beginner-friendly primer so you can reproduce the work, not just nod along.

  • 🔑 Key Insight: Linux is open-source, stable, secure, and flexible. No antivirus woes like Windows—ideal for cloud servers! Its community-driven vibe, with GitHub repos for notes and commands, fuels collaborative DevOps magic.
  • 📊 Stats That Hook: 80-90% of cloud workloads & containers relies on Linux. Also Terraform, Ansible & similar tools are built around Linux Environments. Skip it, and your DevOps house crumbles! 😅 Fellow learners raved how this dominance turned theory into practice, mastering commands before advancing.

🧠 Demystifying Operating Systems & Linux Architecture

🤖 An OS is your computer's "brain," juggling hardware like CPU, RAM, and storage while handling resources, processes, files, and security. Linux nails this with killer management tools.

  • 🛡️ Core Components: Kernel bridges software/hardware for heavy lifts; layers include utilities, apps, and interfaces. Perfect for debugging buggy apps by peeking at kernel chats.
  • 📚 Distributions Galore: Ubuntu for newbies, CentOS/Amazon Linux for pros. We rocked Ubuntu and Amazon Linux 2—pick by provider (e.g., Amazon Linux for AWS). Cloud servers use CLI via SSH, no GUI bullshit; shell like bash runs commands for installs and file wrangling.

🧭 Linux architecture — the simple map

Think in layers: Hardware → Kernel → Shell → Utilities → Applications → User. The kernel talks to hardware, the shell translates your text into kernel actions, and utilities are the building blocks you use every day. This layered model explains why Linux is both light and powerful.

Linux Architecture Diagram


💻 Hands-On: Setting Up Linux VM on AWS EC2

🌥️ Theory? Nah—straight to action! Let's spin up a Linux VM on AWS EC2 (free tier to dodge bills). Disk space snags? Default 8GB fills fast; bump to 16GB with lsblk, sudo growpart /dev/xvda 1, and sudo resize2fs /dev/xvda1—check via df -h.

  • 🔑 Steps to Launch:
    • Log into AWS, pick region (e.g., Mumbai for speed in India), launch EC2 named "Linux demo."
    • Grab AMI like Ubuntu 22.04 LTS or Amazon Linux 2023, t3.micro (free tier), key pair for SSH. Add inbound rules: SSH (22), HTTP (80).
    • Connect: chmod 400 key.pem for permissions, then ssh -i key.pem ubuntu@public-ip (or ec2-user@ for Amazon). Windows? Git Bash saves the day. Clean messes with sudo apt-get purge -y nodejs npm and sudo apt-get autoremove -y; reinstall via nvm for version control. > - ⚠️ Pro Tip: whoami checks user (regular vs. root); sudo su elevates. Commands? Command + option (e.g., -i) + argument (e.g., key.pem).

aws-ec2


🛠️ Linux Shell & Command Mastery: From Basics to Power Moves

📟 Shell's your CLI command hub—servers skip GUIs. Commands? Three parts: action, modifier, input—like echo -n "hello" (no newline).

commands

  • 🚀 Navigation Essentials:

    • pwd: Spits current dir showing current working directory — vital to not get lost deploying!
    • cd: Jumps dirs—e.g., cd /home/user for quick hops & moving arounf the filesystem.
    • ls: Lists stuff — -l for deets, -a for hidden gems.
  • 📝 File Ops:

    • touch: Makes empty files—e.g., touch notes.txt.
    • nano/vim: Edit kings—nano App.js (Ctrl+O save, Ctrl+X exit); vim? i insert, :wq save/quit.
    • cat: Views files—e.g., cat config.txt for fast peeks.
    • file: IDs types—e.g., file pic.png says "PNG image."
    • mv: Moves/renames—e.g., mv old new.
    • cp: Copies— -r for folders.
    • rm: Deletes— -rf is nuclear for force-recursive (careful before execution, triple-check paths! 🔥).
  • 🔒 Permissions & Ownership:

    • chmod: Tweaks access—e.g., chmod 755 file (owner rwx, others rx); -R recursive.
    • chown: Shifts owner/group—e.g., chown user:group file.
    • grep: Hunts text, used for pattern matching —e.g., grep user /etc/passwd finds accounts.
  • 🌐 Advanced Utils:

    • useradd/passwd: Adds users, sets passwords.
    • groupadd/usermod: Group magic—add users to groups.
    • scp: Secure transfers—e.g., scp local user@remote:/path.
    • curl: Grabs URLs—e.g., curl site.com.
    • find: Hunts files—e.g., find . -name "*.txt".
    • tar: Archives—e.g., tar -czf backup.tar.gz dir/.
    • zip/unzip: Zips—e.g., zip -r proj.zip dir/.
    • less/more: Pages big files—e.g., less logs.txt.
    • ssh: Remotes—e.g., ssh user@ip; ssh-keygen for keys.
    • sudo: Superpowers—e.g., sudo apt update.
    • apt/dnf: Installs—e.g., sudo apt install git.
    • top: Watches processes/CPU/mem.
    • history — shows your command history so you can re-run using !54 where 54 is the command no. in history file.

These are your "Swiss Army knife" for efficiency—man for manuals beats memorizing! Demoed static site deploy: SCP upload, dir nav, Nginx serve.

commands-2


🔄 Process Management: Keeping Your System in Check

🕹️ Processes: Running program instances—foreground (e.g., vim interactive) vs. background (daemons like nginx). Each gets a PID.

  • 📈 Monitoring Tools:

    • ps -e: All processes; ps aux | grep nginx : list/filter processes.
    • top: Live view — P sorts CPU, M mem, q quits.
    • pstree: parent-child relationships of processes in Hierarchy tree.
    • kill <PID>: Ends it — -9 force stops it.
    • systemctl start nginx / systemctl enable nginx — manage services on modern distros.
  • ⚙️ Why It Matters: Hunts resource hogs to dodge crashes. Install as root with yum/apt, manage services via systemctl (e.g., systemctl start nginx).

Gather info: uname -a (system deets), uptime (runtime/users), who (logins), free -h (mem), df -h (disk), du -sh /var/* (sizes).

sys-monitoring


🌐 Networking Commands: Connectivity & Troubleshooting

🔌 Apps map IP to ports (nginx on 80)—debug to keep 'em reachable.

  • 📡 Key Commands:
    • ifconfig: Interfaces/IP/MAC.
    • ping -c 4 host: Connectivity test with 4 packet of requests.
    • netstat -tulnp: CHeck Ports/services.
    • dig/host domain: DNS lookups.
    • wget url: Downloads file using CLI.
    • hostname: Your machine's name.

networking


📝 Deploying a React App: Hands-On Milestone

Check out Detailed Blog Deploy a React App on Ubuntu Web Server in AWS CLoud [week-1]

DevOps mindset: Automate, secure, scale! 🌟

Assignment


🎉 Wrap-up

This is the 2nd blog post of the DevOps series covering the lessons from Week 1 of the free DevOps cohort by Pravin Mishra sir 🙏!

The posting streak continues on the DevOps Series not only to keep myself accountable and share what actually works in the trenches but also to keep track of my work in this fast-evolving tech world, we tend to forget things if not documented! 🎉

aws

What’s your favorite Linux command? Drop it below — and if you want, I’ll make a tiny script or cheat sheet for it next for my X(formerly Twitter) account so you can follow-up!.😁

Stay tuned for Week 2—Git & GitHub incoming!🐙🚀

Top comments (0)