Chapter 4: Linux Advanced Commands
4.10 Environment variables
Friends, environment variables are the shell's little notes – information like HOME, PATH and USER that every program can read. Keep secrets such as the database password out of your code, in these variables or in a .env file.
मित्रांनो, environment variables म्हणजे शेलच्या छोट्या चिठ्ठ्या – HOME, PATH, USER सारखी माहिती सगळे प्रोग्राम्स वाचू शकतात. डेटाबेस पासवर्डसारखे सिक्रेट्स कोडमध्ये नाही, अशा variables मध्ये किंवा .env फाइलमध्ये ठेवा.
दोस्तों, environment variables मतलब शेल की छोटी पर्चियाँ – HOME, PATH, USER जैसी जानकारी सारे प्रोग्राम्स पढ़ सकते हैं. डेटाबेस पासवर्ड जैसे सीक्रेट्स कोड में नहीं, ऐसे variables में या .env फ़ाइल में रखो.
echo $HOME $USER $PATH $SHELL
env | sort # all environment variables
export APP_ENV=production # set for this session and child processes
echo $APP_ENV
unset APP_ENV
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc # make permanent for your user
source ~/.bashrc # reload without logging out
Keep secrets out of code
Store database passwords in environment variables or a .env file with permission 600, never hard-coded in files that go to GitHub.
Ravindra Bagale's Tip
Many students run export APP_ENV=production, log out, and the next day the variable is gone. export lasts only for that session – to make it permanent, write it in ~/.bashrc and run source ~/.bashrc. And don't write NAME = "Asha" with spaces around the = – you get an error.
Ravindra Bagale's Tip – मराठी
बरेच students export APP_ENV=production करून logout करतात आणि दुसऱ्या दिवशी variable गायब. export फक्त त्या session पर्यंत चालतो – कायमसाठी ~/.bashrc मध्ये लिहा आणि source ~/.bashrc करा. आणि NAME = "Asha" असं = भोवती space देऊ नका, error येतो.
Ravindra Bagale's Tip – हिंदी
बहुत से students export APP_ENV=production करके logout करते हैं और अगले दिन variable ग़ायब. export सिर्फ़ उसी session तक चलता है – हमेशा के लिए ~/.bashrc में लिखो और source ~/.bashrc करो. और NAME = "Asha" जैसे = के आस-पास space मत दो, error आता है.
Lab
Chala, export SHOP=mauli-dairy kara aani echo $SHOP bagha. Navin terminal ughdun parat echo $SHOP kara – rikama aala ka? Mag echo 'export SHOP=mauli-dairy' >> ~/.bashrc aani source ~/.bashrc karun navin terminal madhe parat check kara.
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.