Tools


Tools Master Quiz

A comprehensive mix of all tools quizzes.

What is the standard syntax to define a basic build rule in a Makefile?

What specific whitespace character MUST be used to indent the command/recipe lines in a Makefile rule?

How do you reference a variable (or macro) named ‘CC’ in a Makefile command?

What Automatic Variable represents the file name of the target of the rule?

What Automatic Variable represents the name of the first prerequisite?

What Automatic Variable represents the names of all the prerequisites, with spaces between them?

What wildcard character is used to define a Pattern Rule (a generic rule applied to multiple files)?

What special target is used to declare that a target name is an action (like ‘clean’) and not an actual file to be created?

What metacharacter can be placed at the very beginning of a recipe command to suppress make from echoing the command to the terminal?

What syntax is used for string substitution on a variable, such as changing all .c extensions in $(SRCS) to .o?

You have some uncommitted, incomplete changes in your working directory, but you need to switch to another branch to urgently fix a bug. How do you temporarily save your current work without making a messy commit?

You know a bug was introduced recently, but you aren’t sure which commit caused it. How do you perform a binary search through your commit history to find the exact commit that broke the code?

You are looking at a file and want to know exactly who last modified a specific line of code, and in which commit they did it.

You want to safely ‘undo’ a previous commit that introduced an error, but you don’t want to rewrite history or force-push. How do you create a new commit with the exact inverse changes?

You want to see exactly what has changed in your working directory compared to your last saved snapshot (the most recent commit).

You have a feature branch with several experimental commits, but you only want to move one specific, completed commit over to your main branch.

You want to integrate a feature branch into main, but instead of bringing over all 15 tiny incremental commits, you want them combined into one clean commit on the main branch.

You are building a massive project and want to include an entirely separate external Git repository as a subdirectory within your project, while keeping its history independent.

You are starting a brand new project in an empty folder on your computer and want Git to start tracking changes in this directory.

You have just installed Git on a new computer and need to set up your username and email address so that your commits are properly attributed to you.

You’ve made changes to three different files, but you only want two of them to be included in your next snapshot. How do you move those specific files to the staging area?

You’ve lost track of what you’ve been doing. You want a quick overview of which files are modified, which are staged, and which are completely untracked by Git.

You have staged all the files for a completed feature and are ready to permanently save this snapshot to your local repository’s history with a descriptive message.

You want to review the chronological history of all past commits on your current branch, including their author, date, and commit message.

You’ve made edits to a file but haven’t staged it yet. You want to see the exact lines of code you added or removed compared to what is currently in the staging area.

You want to start working on a completely new feature in isolation without affecting the main codebase.

You are currently on your feature branch and need to switch your working directory back to the ‘main’ branch.

Your feature branch is complete, and you want to integrate its entire commit history into your current ‘main’ branch.

Instead of creating a merge commit, you want to take the commits from your feature branch and re-apply them directly on top of the latest ‘main’ branch to create a clean, linear history.

You want to start working on an open-source project hosted on GitHub. How do you download a full local copy of that repository to your machine?

Your team members have uploaded new commits to the shared remote repository. You want to fetch those changes and immediately integrate them into your current local branch.

You have finished making several commits locally and want to upload them to the remote GitHub repository so your team can see them.

You have a specific commit hash and want to see detailed information about it, including the commit message, author, and the exact code diff it introduced.

You want to start working on a new feature in isolation. How do you create a new branch called ‘feature-auth’ and immediately switch to it in a single command?

You accidentally staged a file you didn’t intend to include in your next commit. How do you move it back to the working directory without losing your modifications?

You made some experimental changes to a file but want to discard them entirely and revert to the version from your last commit.

You merge a feature branch into main, and Git performs the merge without creating a new merge commit — it simply moves the ‘main’ pointer forward. What type of merge is this, and when does it occur?

You want to safely inspect the codebase at a specific older commit without modifying any branch. How do you do this?

Write a basic Makefile rule to compile a single C source file (main.c) into an executable named app.

Write a Makefile snippet that defines variables for the C compiler (gcc) and standard compilation flags (-Wall -g), and uses them to compile main.c into main.o.

Write a standard clean target that removes all .o files and an app executable, ensuring it runs even if a file literally named ‘clean’ is created in the directory.

Write a generic pattern rule to compile any .c file into a corresponding .o file, using automatic variables for the target name and the first prerequisite.

Given a variable SRCS = main.c utils.c, write a variable definition for OBJS that dynamically replaces the .c extension with .o for all files in SRCS.

Write a rule to link an executable myprog from a list of object files stored in the $(OBJS) variable, using the automatic variable that lists all prerequisites.

Write the conventional default target rule that is used to build multiple executables (e.g., app1 and app2) when a user simply types make without specifying a target.

Write a run target that executes an output file named ./app, but suppresses make from printing the command to the terminal before running it.

Write a variable definition SRCS that uses a Make function to dynamically find and list all .c files in the current directory.

Write a generic rule to create a build directory build/ using the mkdir command.

You need to see a list of all the files and folders in your current directory. What command do you use?

You are currently in your home directory and need to navigate into a folder named ‘Documents’. Which command achieves this?

You want to quickly view the entire contents of a small text file named ‘config.txt’ printed directly to your terminal screen.

You need to find every line containing the word ‘ERROR’ inside a massive log file called ‘server.log’.

You wrote a new bash script named ‘script.sh’, but when you try to run it, you get a ‘Permission denied’ error. How do you make the file executable?

You want to rename a file from ‘draft_v1.txt’ to ‘final_version.txt’ without creating a copy.

You are starting a new project and need to create a brand new, empty folder named ‘src’ in your current location.

You want to view the contents of a very long text file called ‘manual.txt’ one page at a time so you can scroll through it.

You need to create an exact duplicate of a file named ‘report.pdf’ and save it as ‘report_backup.pdf’.

You have a temporary file called ‘temp_data.csv’ that you no longer need and want to permanently delete from your system.

You want to quickly print the phrase ‘Hello World’ to the terminal or pass that string into a pipeline.

You want to know exactly how many lines are contained within a file named ‘essay.txt’.

You need to perform an automated find-and-replace operation on a stream of text to change the word ‘apple’ to ‘orange’.

You have a space-separated log file and want a tool to extract and print only the 3rd column of data.

You want to store today’s date (formatted as YYYY-MM-DD) in a variable called TODAY so you can use it to name a backup file dynamically.

A variable FILE holds the value my report.pdf. Running rm $FILE fails with a ‘No such file or directory’ error for both ‘my’ and ‘report.pdf’. How do you fix this?

You are writing a script that requires exactly two arguments. How do you check how many arguments were passed to the script so you can print a usage error if the count is wrong?

You want to create a directory called ‘build’ and then immediately run cmake .. inside it, but only if the directory creation succeeded — all in a single command.

At the start of a script, you need to change into /deploy/target. If that directory doesn’t exist, the script must abort immediately — write a defensive one-liner.

You want to delete all files ending in .tmp in the current directory using a single command, without listing each filename explicitly.

Given the snippet app: main.o network.o utils.o followed by the command $(CC) $(CFLAGS) $^ -o $@, what exactly does the command evaluate to if CC=gcc and CFLAGS=-Wall?

If a C project Makefile contains SRCS = main.c math.c io.c and OBJS = $(SRCS:.c=.o), what does OBJS evaluate to?

Read this common pattern rule: %.o: %.c followed by $(CC) $(CFLAGS) -c $< -o $@. If make uses this rule to build utils.o from utils.c, what does $< represent?

You see the line CC ?= gcc at the top of a Makefile. What happens if a developer compiles the project by typing make CC=clang in their terminal?

A C project has a rule clean: rm -f *.o myapp. Why is it critical to also include .PHONY: clean in this Makefile?

In the rule main.o: main.c main.h types.h, what happens if you edit and save types.h?

You are reading a Makefile and see @echo "Compiling $@..." followed by @$(CC) -c $< -o $@. What do the @ symbols do?

What is the conventional purpose of the CFLAGS variable in a C Makefile?

What is the conventional purpose of the LDFLAGS or LDLIBS variables in a C Makefile?

A C project has multiple executables: a server and a client. The Makefile starts with all: server client. What happens if you just type make?

What metacharacter asserts the start of a string?

What metacharacter asserts the end of a string?

What syntax is used to define a Character Class (matching any single character from a specified group)?

What syntax is used inside a character class to act as a negation operator (matching any character NOT in the group)?

What metacharacter is used to match any single digit?

What meta character is used to match any ‘word’ character (alphanumeric plus underscore)?

What meta character is used to match any whitespace character (spaces, tabs, line breaks)?

What metacharacter acts as a wildcard, matching any single character except a newline?

What quantifier specifies that the preceding element should match ‘0 or more’ times?

What quantifier specifies that the preceding element should match ‘1 or more’ times?

What quantifier specifies that the preceding element should match ‘0 or 1’ time?

What syntax is used to specify that the preceding element must repeat exactly n times?

What syntax is used to create a group?

What is the syntax used to create a Named Group?

Write a regex to validate a standard email address (e.g., user@domain.com).

Write a regex to match a standard US phone number, with optional parentheses and various separators (e.g., 123-456-7890 or (123) 456-7890).

Write a regex to match a 3 or 6 digit hex color code starting with a hashtag (e.g., #FFF or #1A2B3C).

Write a regex to validate a strong password (at least 8 characters, containing at least one uppercase letter, one lowercase letter, and one number).

Write a regex to match a valid IPv4 address (e.g., 192.168.1.1).

Write a regex to extract the domain name from a URL, ignoring the protocol and ‘www’ (e.g., extracting ‘example.com’ from ‘https://www.example.com/page’).

Write a regex to match a date in the format YYYY-MM-DD with basic month and day validation.

Write a regex to match a time in 24-hour format (HH:MM).

Write a regex to match an opening or closing HTML tag.

Write a regex to find all leading and trailing whitespaces in a string (commonly used for string trimming).

Tools Master Quiz

A comprehensive mix of all tools flashcards.

A developer needs to parse a massive log file, extract IP addresses, sort them, and count unique occurrences. Instead of writing a 500-line Python script, they use cat | awk | sort | uniq -c. Why is this approach fundamentally preferred in the UNIX environment?

Correct Answer:

A script runs a command that generates both useful output and a flood of permission error messages. The user runs script.sh > output.txt, but the errors still clutter the terminal screen while the useful data goes to the file. What underlying concept explains this behavior?

Correct Answer:

A C++ developer writes a Bash script with a for loop. Inside the loop, they declare a variable temp_val. After the loop finishes, they try to print temp_val expecting it to be undefined or empty, but it prints the last value assigned in the loop. Why did this happen?

Correct Answer:

You want to use a command that requires two file inputs (like diff), but your data is currently coming from the live outputs of two different commands. Instead of creating temporary files on the disk, you use the <(command) syntax. What is this concept called and what does it achieve?

Correct Answer:

A script contains entirely valid Python code, but the file is named script.sh and has #!/bin/bash at the very top. When executed via ./script.sh, the terminal throws dozens of ‘command not found’ and syntax errors. What is the fundamental misunderstanding here?

Correct Answer:

A developer uses the regular expression [0-9]{4} to validate that a user’s input is exactly a four-digit PIN. However, the system incorrectly accepts ‘12345’ and ‘A1234’. What crucial RegEx concept did the developer omit?

Correct Answer:

You are designing a data pipeline in the shell. Which of the following statements correctly describe how UNIX handles data streams and command chaining? (Select all that apply)

Correct Answers:

You’ve written a shell script deploy.sh but it throws a ‘Permission denied’ error or fails to run when you type ./deploy.sh. Which of the following are valid reasons or necessary steps to successfully execute a script as a standalone program? (Select all that apply)

Correct Answers:

In Bash, exit codes are crucial for determining if a command succeeded or failed. Which of the following statements are true regarding how Bash handles exit statuses and control flow? (Select all that apply)

Correct Answers:

When you type a command like python or grep into the terminal, the shell knows exactly what program to run without you providing the full file path. How does the $PATH environment variable facilitate this, and how is it managed? (Select all that apply)

Correct Answers:

A developer writes LOGFILE="access errors.log" and then runs wc -l $LOGFILE. The command fails with ‘No such file or directory’ errors for both ‘access’ and ‘errors.log’. What is the root cause?

Correct Answer:

A script is invoked with ./deploy.sh production 8080 myapp. Inside the script, which variable holds the value 8080?

Correct Answer:

A script contains the line: cd /deploy/target && ./run_tests.sh && echo 'All tests passed!'. If ./run_tests.sh exits with a non-zero status code, what happens next?

Correct Answer:

Which of the following statements correctly describe Bash quoting and command substitution behavior? (Select all that apply)

Correct Answers:

Arrange the pipeline fragments to build a command that extracts all ERROR lines from a log, sorts them, removes duplicates, and counts how many unique errors remain.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
grep 'ERROR' server.log|sort|uniq|wc -l

Arrange the lines to write a shell script that validates a command-line argument, prints an error to stderr if missing, and exits with a non-zero code.

Drag lines into the solution area in the correct order (some items are distractors that should not be used):
↓ Drop here ↓
Correct order:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Error: no filename given" >&2
exit 1
fi
echo "Processing $1..."

Arrange the pipeline fragments to find the 5 most frequently occurring IP addresses in an access log.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' access.log|sort|uniq -c|sort -rn|head -5

Arrange the fragments to redirect both stdout and stderr of a deployment script into a single log file.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
./deploy.sh>output.log2>&1

Arrange the pipeline to count how many files under src/ contain the word TODO.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
grep -rl 'TODO' src/|wc -l

Arrange the fragments to grant execute permission on a script and immediately run it.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
chmod +x script.sh&&./script.sh

Which of the following best describes the core difference between centralized and distributed version control systems (like Git)?

Correct Answer:

What are the three primary local states that a file can reside in within a standard Git workflow?

Correct Answer:

What does the command git diff HEAD compare?

Correct Answer:

Which Git command should you NEVER use on a shared branch because it can permanently overwrite and destroy work pushed by other team members?

Correct Answer:

You have some uncommitted, incomplete changes in your working directory, but you need to switch to another branch to urgently fix a bug. Which command is best suited to temporarily save your current work without making a messy commit?

Correct Answer:

What happens when you enter a ‘Detached HEAD’ state in Git?

Correct Answer:

Which Git command utilizes a binary search through your commit history to help you pinpoint the exact commit that introduced a bug?

Correct Answer:

What is the primary purpose of Git Submodules?

Correct Answer:

Which of the following are advantages of a Distributed Version Control System (like Git) compared to a Centralized one? (Select all that apply)

Correct Answers:

Which of the following represent the core local states (or areas) where files can reside in a standard Git architecture? (Select all that apply)

Correct Answers:

Which of the following commands are primarily used to review changes, history, or differences in a Git repository? (Select all that apply)

Correct Answers:

In which of the following scenarios would using git stash be considered an appropriate and helpful practice? (Select all that apply)

Correct Answers:

Which of the following are valid methods or strategies for integrating changes from a feature branch back into the main codebase? (Select all that apply)

Correct Answers:

A faulty commit was pushed to a shared ‘main’ branch last week and your teammates have already synced it. Why should you use git revert to fix this rather than git reset --hard followed by a force-push?

Correct Answer:

When integrating a feature branch into ‘main’, under what condition will Git perform a fast-forward merge rather than creating a three-way merge commit?

Correct Answer:

What does the file .git/HEAD contain when you are checked out on a branch, compared to when you are in a detached HEAD state?

Correct Answer:

Arrange the Git commands into the correct order to: create a feature branch, make changes, and integrate them back into main via a merge.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git switch -c feature&&git add app.py&&git commit -m 'Add feature'&&git switch main&&git merge feature

Arrange the commands to safely stash your work, pull remote changes, and restore your stashed work.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git stash&&git pull&&git stash pop

Arrange the commands to undo a bad commit on a shared branch safely: first identify the commit, then revert it, then push the fix.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git log --oneline&&git revert &&git push</code> </span> </div> </div>

Arrange the commands to initialize a new repository and record an initial commit.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git init&&git add .&&git commit -m 'Initial commit'

Arrange the commands to register a remote called origin and push the main branch to it for the first time.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git remote add origin &&git push -u origin main</code> </span> </div> </div>

Arrange the commands to stage a forgotten file and fold it into the last commit without changing the commit message.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
git add forgotten.py&&git commit --amend --no-edit

What is the primary mechanism make uses to determine if a target needs to be rebuilt?

Correct Answer:

What specific whitespace character MUST be used to indent the command/recipe lines in a Makefile rule?

Correct Answer:

What does the automatic variable $@ represent in a Makefile rule?

Correct Answer:

Why is the .PHONY directive used in Makefiles (e.g., .PHONY: clean)?

Correct Answer:

If a user runs the make command in their terminal without specifying a target, what will make do?

Correct Answer:

You have a pattern rule: %.o: %.c. What does the % symbol do?

Correct Answer:

Which of the following are primary benefits of using a Makefile instead of a standard procedural Bash script (build.sh)? (Select all that apply)

Correct Answers:

Which of the following are valid Automatic Variables in Make? (Select all that apply)

Correct Answers:

In standard C/C++ project Makefiles, which of the following variables are common conventions used to increase flexibility? (Select all that apply)

Correct Answers:

How does the evaluation logic of a Makefile differ from a standard cookbook recipe or procedural script? (Select all that apply)

Correct Answers:

You are tasked with extracting all data enclosed in HTML <div> tags. You write a regular expression, but it consistently fails on deeply nested divs (e.g., <div><div>text</div></div>). From a theoretical computer science perspective, why is standard RegEx the wrong tool for this?

Correct Answer:

A developer writes a regex to parse a log file: ^.*error.*$. They notice that while it works, it runs much slower than expected on very long log lines. What underlying behavior of the .* token is causing this inefficiency?

Correct Answer:

You need to validate user input to ensure a password contains both a number and a special character, but you don’t know what order they will appear in. What mechanism allows a RegEx engine to assert these conditions without actually ‘consuming’ the string character by character?

Correct Answer:

You are given the regex (?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2}) and apply it to the string 2026-04-01. After a successful match, which of the following correctly describes how you can access the captured month value?

Correct Answer:

When writing a complex regex to extract phone numbers, you use parentheses (...) to group the area code so you can apply a ? quantifier. However, you also want to extract the area code by name for later use in your code. What is the best approach?

Correct Answer:

You write a regex to ensure a username is strictly alphanumeric: [a-zA-Z0-9]+. However, a user successfully submits the username admin!@#. Why did this happen?

Correct Answer:

Which of the following scenarios are highly appropriate use cases for Regular Expressions? (Select all that apply)

Correct Answers:

In the context of evaluating a regex for data extraction, what represents a ‘False Positive’ and a ‘False Negative’? (Select all that apply)

Correct Answers:

You use the regex <.*> to extract a single HTML tag from <b>bold</b> text, but it matches the entire string <b>bold</b> instead of just <b>. What is the simplest fix?

Correct Answer:

Which of the following statements about Lookaheads (?=...) are true? (Select all that apply)

Correct Answers:

Arrange the regex fragments to build a pattern that validates a simple email address like user@example.com. The pattern should be anchored to match the entire string.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Arrange the regex fragments to build a pattern that matches a date in YYYY-MM-DD format (e.g., 2024-01-15). Anchor the pattern.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
^\d{4}-\d{2}-\d{2}$

Arrange the regex fragments to extract the protocol and domain from a URL like https://www.example.com/path. Use a capturing group for the domain.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used):
→ Drop here →
Correct order:
https?://([^/]+)
</div> </div>