Chapter 4: Linux Advanced Commands
Practice Questions and Lab Exercises
Come on, practice time! Do every lab on EC2 and type the commands by hand – copy-paste does not train your hands.
चला, आता प्रॅक्टिस! प्रत्येक लॅब EC2 वर करा आणि कमांड्स हाताने टाइप करा – कॉपी-पेस्टने हात बसत नाही.
चलो, अब प्रैक्टिस! हर लैब EC2 पर करो और कमांड्स हाथ से टाइप करो – कॉपी-पेस्ट से हाथ नहीं बैठता.
- Write a command to count how many times
404appears in an Nginx access log. - Find all
.conffiles under/etcthat were modified in the last 2 days. - Using
awk, print the 1st and 9th columns (IP and status code) of an access log. - Explain
>,>>,2>&1and the pipe symbol with examples. - What is the difference between
service nginx restartandservice nginx reload? Betweenservice nginx startandsystemctl enable nginx? - Which command shows the ports on which a server is listening? How do you know whether an app is exposed to the internet?
- Write a cron entry that runs
/home/ubuntu/backup.shevery Sunday at 11:00 PM. - Lab: Write a script
backup.shthat creates~/backups/web-<date>.tar.gzof/var/www/htmland deletes backups older than 7 days. - Lab: Use
scpto upload a folder to your EC2 instance andrsyncto sync only changed files.
Quick Revision
grep(search text),find(search files),awk(columns),sed(replace).- Pipes, redirection
> >> 2> 2>&1,teefor writing root-owned files, here-docs for multi-line files. tar -czvfcreate,tar -xzvfextract.sudo service <name> start|stop|restart|reload|status; boot-time withsudo systemctl enable <name>; logs withjournalctl -u <name> -f.- Network:
ip a,ss -tlnp,curl -I,dig,nc -zv. Disk:df -h,du -sh,lsblk -f,blkid,/etc/fstab. crontab -e(5 fields).export VAR=value,~/.bashrc.ssh -i,scp -r,rsync -avz.- Scripts:
#!/bin/bash,chmod +x, variables,if,for, functions.
Got it? grep, awk, pipes, services, cron and scripts – these are a cloud engineer's everyday weapons. Now let's move on to the most important service in AWS – EC2.
समजलं का? grep, awk, पाइप्स, सर्व्हिसेस, cron आणि स्क्रिप्ट्स – हेच क्लाउड इंजिनिअरचे रोजचे हत्यार आहेत. आता पुढे जाऊया AWS मधल्या सगळ्यात इम्पॉर्टंट सर्व्हिसकडे – EC2.
समझ आया? grep, awk, पाइप्स, सर्विसेस, cron और स्क्रिप्ट्स – यही क्लाउड इंजीनियर के रोज़ के हथियार हैं. अब आगे चलते हैं AWS की सबसे इम्पॉर्टेंट सर्विस की तरफ़ – EC2.
Extended teaching notes
Why this lesson matters
Cloud security is mostly IAM, network exposure, logging and secure defaults. The shared responsibility model means the provider patches the metal; you patch what you configure.
- No public databases or public admin panels.
- Roles / OIDC instead of long-lived access keys.
- CloudTrail / Activity Logs / Audit Logs on and retained.
- S3/Blob/GCS: Block Public Access; encrypt; least privilege.
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.