Chapter 3: Linux Basic Commands
Friends, from this chapter onwards the terminal is your best friend. If the black screen feels scary at first, don't worry – practise every day for one week and you will become faster on the command line than with the mouse. First let's understand why Linux is so important in the cloud, and then we will type commands together. Our example in this chapter: managing the website files, users and packages on the EC2 server of a dairy brand like Amul (sample data, for practice).
मित्रांनो, या चॅप्टरपासून टर्मिनल तुमचा बेस्ट फ्रेंड आहे. सुरुवातीला काळी स्क्रीन भीतीदायक वाटली तर काळजी करू नका – एक आठवडा रोज प्रॅक्टिस केली की माउसपेक्षा कमांड लाइनवर तुम्ही जास्त फास्ट व्हाल. आधी Linux क्लाउडमध्ये इतकं इम्पॉर्टंट का ते समजून घेऊ, आणि मग कमांड्स एकत्र टाइप करू. या चॅप्टरमध्ये आपलं उदाहरण: Amul-style dairy (सॅम्पल डेटा, सरावासाठी) च्या EC2 सर्व्हरवर वेबसाइटच्या फाइल्स, यूजर्स आणि पॅकेजेस मॅनेज करायचे आहेत.
दोस्तों, इस चैप्टर से टर्मिनल आपका बेस्ट फ़्रेंड है. शुरू में काली स्क्रीन डरावनी लगे तो चिंता मत करो – एक हफ़्ता रोज़ प्रैक्टिस की तो माउस से ज़्यादा कमांड लाइन पर आप फ़ास्ट हो जाओगे. पहले समझते हैं कि Linux क्लाउड में इतना इम्पॉर्टेंट क्यों है, और फिर कमांड्स साथ में टाइप करेंगे. इस चैप्टर में हमारा उदाहरण: Amul-style dairy (सैंपल डेटा, सिर्फ़ अभ्यास के लिए) के EC2 सर्वर पर वेबसाइट की फ़ाइलें, यूज़र्स और पैकेजेस मैनेज करने हैं.
What you will learn in this chapter
- The Linux file-system hierarchy
- Navigating with pwd, ls and cd
- Creating, copying, removing files
- Viewing files and following logs
- Permissions: chmod and chown
- Users, groups and sudo
- Package managers: yum and apt
- Processes, help and editors
Concepts in this chapter
- 3.1Why Linux?
- 3.2Navigation
- 3.3Working with files and directories
- 3.4Viewing files
- 3.5Permissions
- 3.6Users, groups and sudo
- 3.7Package managers
- 3.8Processes
- 3.9Getting help
- 3.10Text editors: nano and vim
Review and practice
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.
Practice Tasks
Dublin Fitness Club is a fitness business in Dublin. Siobhan Murphy looks after its IT and cloud work. They count money in EUR and run their AWS resources in the eu-west-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 12
Easy List all files with details
Why: Hidden files (like .env) and file sizes or owners only show with the right options.
What to do: Show a long listing of every file, including hidden ones, in /var/www/dublinfit.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Create nested folders in one go
Why: Projects need a clean folder tree. Making all levels in one command saves time and avoids errors.
What to do: Create the folder /srv/dublinfit/reports/2026 for Dublin Fitness Club. The parent folders do not exist yet, so create them too.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Show where you are
Why: Before you copy or delete anything, you must know which folder you are in.
What to do: Siobhan Murphy logged in to the Dublin Fitness Club server and is not sure which folder the terminal is in. Print the current folder path.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Read a config file
Why: Reading a file on the screen is the quickest way to check its settings.
What to do: Print the whole file /etc/dublinfit/app.conf on the screen.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Create an empty file
Why: Some apps need a file to exist before they can write to it.
What to do: Create an empty file named orders-eur.csv in the current folder.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Copy a folder with everything inside
Why: A plain copy skips folders. You need the recursive option to copy a whole tree.
What to do: Copy the folder site to a new folder named site-backup (both in the current folder).
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Rename a file
Why: In Linux, renaming is the same as moving a file to a new name.
What to do: Rename the file report.txt to report-dublin.txt.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Go into the logs folder
Why: Moving into a folder makes the next commands shorter.
What to do: Move into the folder /var/log/dublinfit.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy List Availability Zones
Why: Spreading servers across AZs keeps you up if one data centre fails.
What to do: List the Availability Zones in eu-west-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy List your EC2 instances
Why: Before changing anything, see what is running and in which state.
What to do: Show details of all EC2 instances of Dublin Fitness Club in eu-west-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy List all Regions
Why: Choose a Region close to your users for low delay and the right laws.
What to do: List the AWS Regions available to your account.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Delete an old folder
Why: Old build folders waste disk. rm needs the recursive option for folders, and force skips the questions.
What to do: Delete the folder old-build and everything inside it without being asked to confirm each file.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.