π§ Chapter 6: The Ultimate Linux Command Lab¶
This guide combines theory review, sequential hands-on problems, and real-world troubleshooting scenarios. It is designed to take you from a terminal beginner to a confident CLI user.
ποΈ PART 1: Knowledge & Logic Check (Theory Review)¶
Test your understanding before touching the keyboard.
πΉ Section A: Multiple Choice Questions¶
- Which command displays the current logged-in username?
- A)
who - B)
whoami - C)
user - D)
id
- A)
- Which of the following is an "Absolute Path"?
- A)
Documents/notes.txt - B)
../home/student - C)
/home/student/Desktop - D)
./Images
- A)
- To view long file content page-by-page, which command is best?
- A)
cat - B)
more - C)
view - D)
show
- A)
- In the permission string
-rwxr-xr--, what does the first-represent?- A) Directory
- B) Regular file
- C) Hidden file
- D) Executable
- Which numeric value represents 'Read' and 'Write' but NO 'Execute'?
- A) 7
- B) 5
- C) 6
- D) 4
πΉ Section B: Command Logic¶
- How do you exit the
bc(calculator) environment? - Write the command to create nested directories
School/Std11/Computerin one go. - Explain why
rmdirfails if a directory contains even one hidden file. - If you use
cat > myfile.txton an existing file, what happens to the old data? - What is the difference between the
*and?wildcards?
π» PART 2: Hands-on Command Lab (50 Problems)¶
Execute these in your terminal to build muscle memory.
π― Level 1: System Awareness (1-7)¶
- Shell Check: Check which shell you are currently using.
- Calendar: Display the calendar for January 2024 and the entire year 2024.
- Date: Display today's date in
mm/dd/yyformat. - Calculator: Use
bcto calculate45 * 23 + 17and findsqrt(625). - Variable: Create a variable "name" and echo "Hello, [name]!".
- Cleanup: Clear your terminal screen.
- Help: Access the manual for
mkdir.
π Level 2: Directory Operations (8-12)¶
- Structure: Create subfolders
math,science, andenglishinside a folder namedstudies. - Location: Verify your path with
pwd. - Jump: Go back to your home directory from
mathusing a single command. - Remove: Delete the
englishfolder. - Batch: Create
temp1throughtemp4simultaneously.
π Level 3: File Operations (13-20)¶
- Create: Use
cat > notes.txtto write three lines about Linux. - Display: View the content of
notes.txt. - Append: Add "Learning never stops" to the end of
notes.txt. - Merge: Concatenate
notes.txtandmore_notes.txtintoall_notes.txt. - Stats: Find the line, word, and character count of
all_notes.txt. - Copy: Create a
backup_notes.txtfromnotes.txt. - Rename: Change
backup_notes.txttoarchived_notes.txt. - Purge: Delete the
tempfolders and thearchivedfile.
π Level 4: Advanced Filters & Wildcards (21-30)¶
- Hidden: List all files including hidden ones.
- Secret: Create a file named
.secretand see iflsshows it. - Pattern: List all files starting with 'a', 'b', or 'c'.
- Slice: Extract the first 10 characters of
notes.txtusingcut. - CSV: Extract the 1st column from a comma-separated
data.txt. - Sort: Sort
data.txtby the second field (Age). - Search: Find the line containing "John" in
data.txt. - Snippet: Show only the first 2 and last 2 lines of a file.
- Compare: Find the differences between two similar text files.
- Join: Use
pasteto join two files horizontally.
π Level 5: Permissions & Security (31-34)¶
- Status: Check the long-format listing (
ls -l) of a script. - CHMOD: Set permissions to
744(Owner: all, Others: read). - Restrict: Remove your own write permission.
- Vault: Create a
privatedirectory accessible only to you.
β‘ Level 6: Redirection & Piping (35-40)¶
- Export: Save your directory list to
files.txt. - Count: Count how many files are in
/binusing a pipe. - Users: Save the top 5 users from
/etc/passwdtousers.txt. - Bash: Find all users using the bash shell.
- Pipeline: Sort
data.txtand save it tofinal.txt. - Transform: Convert a file's text to all UPPERCASE using
tr.
π οΈ Level 7: Troubleshooting (42-50)¶
- Force delete a non-empty directory.
- Find a command related to "copy" using
apropos. - Identify the owner and group of a system file.
- Rename a file that has a space in its name (e.g.,
my file.txt). - Search for a specific word inside all
.txtfiles in a folder. - Find the differences between
config.oldandconfig.new. - Count how many times the word "error" appears in a log file.
- See the last 10 commands you typed (Hint: use
history). - The Master Pipeline: List β filter
.docβ sort β save tolist.txt.
π PART 3: The Capstone Challenges¶
Complex tasks that require multiple commands to solve.
ποΈ Challenge 1: The Master Flow Lab¶
- Find your username and current date.
- In Home, create
Project/CodesandProject/Notes. - Move into
Project/Notes. - Create
intro.txt,data.txt, andfinal.doc. - Write "Linux Master" into
intro.txt. - Move
final.docinto theCodesfolder using a relative path. - Copy
intro.txttobackup.txt. - Change
backup.txtpermission to400. - Go back to
Projectand delete theNotesfolder and everything inside it.
ποΈ Challenge 2: The Comprehensive Project¶
- The Linux Organizer:
- Create
linux_practicewith subfoldersdocuments,scripts, andlogs. - Create
report1.txtandreport2.txtinsidedocuments. - Merge them into
final_report.txt. - Create a recursive inventory of the whole project and save it to
system_map.txt. - Make every file in
scriptsexecutable.
- Create
π‘ Final Mentor's Tip¶
"Commands are like vocabulary. The more you use them in real scenarios, the faster you will speak the language of Linux. Don't just readβtype!" π§π