Text preview & study summary

Linux Command Line Basics

A free sample of 5 questions from this quiz, shown in full with answer choices and explanations. No interactivity — everything is visible on this page for study and review.

Want to test your knowledge? Launch the Interactive Exam Simulator

Question 1

Which command would you use to find all `.log` files in `/var` and its subdirectories that are larger than 100MB?

Answer choices

  • A. `ls -r /var *.log --size +100M`

  • B. `grep -r "*.log" /var -size +100M`

  • C. `find /var -name "*.log" -size +100M` (Correct)

  • D. `locate /var -type f -size +100M -name "*.log"`

Explanation

`find` is the correct tool for searching files by attributes. Syntax: `find [path] [options]`. `-name "*.log"` matches filenames ending in `.log`; `-size +100M` matches files larger than 100 megabytes. `find` also supports `-type f` (files only), `-mtime` (modification time), `-user`, and can execute commands on found files with `-exec`. The `locate` command searches a database (not live filesystem) and doesn't support complex filters like size.

Question 2

Which of the following commands can be used to view the contents of a text file in the terminal? **(Select all that apply)**

Answer choices

  • A. cat (Correct)

  • B. less (Correct)

  • C. more (Correct)

  • D. head (Correct)

  • E. grep

Explanation

Multiple commands can display file contents: `cat` shows entire file at once; `less` shows page by page with scrolling (preferred for large files); `more` shows page by page (older, less features than less); `head` shows the first 10 lines (default); `tail` shows the last 10 lines (also `tail -f` follows live updates). `grep` searches patterns — while it displays matching lines, its primary purpose is searching rather than viewing.

Question 3

The command `ps aux | grep nginx` uses a [[blank1]] to pass the output of `ps aux` as input to the `grep` command.

Explanation

The pipe `|` is a fundamental Linux construct that connects the stdout of one command to the stdin of another. `ps aux` lists all running processes; the output is "piped" to `grep nginx`, which filters for lines containing "nginx". This is used to check if a specific process is running. Command chaining with pipes is one of the most powerful features of the Linux command line.

Question 4

What does the `pwd` command do?

Answer choices

  • A. Changes the password for the current user

  • B. Displays the current working directory path (Correct)

  • C. Lists files with their permissions

  • D. Creates a new directory

Explanation

`pwd` stands for "Print Working Directory." It displays the full absolute path of the directory you are currently in (e.g., `/home/username/Documents`). This is useful when you're navigating the file system and need to know exactly where you are. It is particularly helpful in scripts to get the script's running directory.

Question 5

The `etc` directory in Linux contains user home directories.

Answer choices

  • A. True

  • B. False (Correct)

Explanation

`/etc` contains system-wide configuration files (e.g., `/etc/passwd`, `/etc/hosts`, `/etc/fstab`). User home directories are stored in `/home` (e.g., `/home/username`). The root user's home is at `/root`. Other key Linux directories: `/var` (variable data like logs), `/tmp` (temporary files), `/usr` (user programs), `/bin` (essential binaries), `/sbin` (system binaries), `/proc` (virtual filesystem with process info).