Skip to main content

Stage 2: Command Adventurer

You will be introduced to the essential Linux commands for navigation, file handling, and text processing. Build confidence in using the terminal and prepare them for command‑based interview questions.


Hackbook Overview

1. Navigating the File System

  • pwd: Print current working directory.
  • ls: List files and directories.
  • cd: Change directory.

2. File and Directory Management

  • touch: Create empty files.
  • mkdir: Create directories.
  • rm: Remove files.
  • rmdir: Remove directories.
  • cp: Copy files.
  • mv: Move or rename files.

3. Viewing and Editing Files

  • cat: Display file contents.
  • less/more: View files page by page.
  • nano/vi: Edit files directly in terminal.

4. Searching and Filtering

  • grep: Search text patterns in files.
  • find: Locate files and directories.
  • wc: Count words, lines, characters.

5. Why This Matters in Interviews

  • Interviewers often ask candidates to demonstrate basic command usage.
  • Shows practical ability to navigate and manipulate Linux systems.

Hands‑On Practice

  • Create a directory practice_dir and a file notes.txt inside it.
  • Add text to notes.txt using echo "Hello Linux" > notes.txt.
  • Use grep "Linux" notes.txt to search for the word.
  • Rename notes.txt to linux_notes.txt using mv.
  • Delete the file and directory safely.

Interview Question Bank

Conceptual

  • Q1. What command shows your current directory?
    A1. pwd prints the current working directory path.
  • Q2. How do you list hidden files in Linux?
    A2. Use ls -a to display all files, including hidden ones starting with ..
  • Q3. What’s the difference between rm and rmdir?
    A3. rm removes files (and directories with -r), while rmdir removes empty directories only.

Practical

  • Q4. How do you search for the word “error” inside a log file?
    A4. Run grep "error" logfile.log.
  • Q5. How do you count the number of lines in a file?
    A5. Use wc -l filename.
  • Q6. How do you copy a file from one directory to another?
    A6. Run cp source.txt /path/to/destination/.

Scenario‑Based

  • Q7. You need to find all .conf files under /etc. What command do you use?
    A7. find /etc -name "*.conf".
  • Q8. A file is too large to view at once. How do you read it efficiently?
    A8. Use less filename to scroll through the file page by page.
  • Q9. You accidentally deleted a file with rm. Can you recover it?
    A9. Not directly — rm permanently deletes files unless backups or snapshots exist.

Behavioral Based

  • Q10. Tell me about a time you used Linux commands to solve a problem.
    A10. Example: “I used grep and find to quickly locate misconfigured files during a deployment, saving hours of manual search.”

Cheatsheet (Quick Notes)

  • Navigation: pwd, ls, cd
  • File Management: touch, mkdir, rm, cp, mv
  • Viewing: cat, less, nano, vi
  • Search: grep, find, wc
  • Hidden Files: ls -a

Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff ♥

Updated on Dec 21, 2025