Quiz

Linux Quiz 3: Intermediate Command-Line and System Administration Practice

Test intermediate Linux skills with 20 questions on filesystems, permissions, text processing, processes, packages, networking, and system information.

Quiz instructions and format

This intermediate Linux quiz contains 20 questions. It combines multiple-choice questions, short answers, command completion, and scenario-based problems. Use a Linux terminal for the command questions when possible.

  • Questions 1–8: multiple choice.
  • Questions 9–14: command completion or short answer.
  • Questions 15–20: scenario-based troubleshooting.

Give yourself one point for each correct answer. A score of 17–20 shows strong readiness for more advanced administration work, 13–16 indicates a solid foundation with a few review areas, 9–12 suggests that the intermediate topics need more practice, and 0–8 means you should review the prerequisite command-line and permissions lessons before retaking the quiz.

Try the questions before reading the answer key. Several commands can have more than one valid solution; the answer key shows a conventional solution and explains the underlying concept.

Part 1: Multiple-choice questions

  1. Your current working directory is /home/alex. Which command changes to /home/alex/projects/app using a relative path?

    • cd /projects/app
    • cd projects/app
    • pwd projects/app
    • mv projects/app
  2. Which command displays hidden files, permissions, ownership, and file sizes in a long listing?

    • ls -r
    • ls -la
    • ls -d
    • ls -t
  3. What does chmod 750 deploy.sh grant?

    • Everyone can read, write, and execute the file.
    • The user has read, write, and execute; the group has read and execute; others have no permissions.
    • The user has read-only access; the group has write access; others can execute.
    • The group owns the file and the user may execute it.
  4. Which expression correctly describes a pipeline?

    • It saves standard error to a file.
    • It sends the standard output of one command to the standard input of another.
    • It runs a command with root privileges.
    • It expands every filename in a directory.
  5. Which signal should normally be tried first when asking a process to terminate cleanly?

    • SIGKILL
    • SIGSTOP
    • SIGTERM
    • SIGHUP in every situation
  6. Which command displays the current user identity and supplementary groups?

    • id
    • jobs
    • df
    • uname
  7. Which statement about package managers is correct?

    • A repository is always a single local package file.
    • APT and DNF install packages but cannot resolve dependencies.
    • A package manager can obtain software from repositories, resolve dependencies, and track installed files.
    • A package file and an installed package are exactly the same thing.
  8. Which command tests name resolution without opening an SSH session?

    • getent hosts server.example
    • chmod server.example
    • free -h server.example
    • du -sh server.example

Part 2: Command completion and short answers

  1. Write commands that create a directory named reports, copy summary.txt into it, and then verify your location and files.

  2. Complete the command to find every file ending in .log below /var/log: find /var/log -name '_____'.

  3. Write a command that finds lines containing ERROR in application.log and counts those lines.

  4. Write commands that send normal output from build.sh to build.log, append later output to that file, and send error output to build-errors.log.

  5. Interpret rwxr-x--- for a regular file. Which permission classes have access, and what numeric mode represents it?

  6. Write a command that adds execute permission for the file's owner without changing other permission bits.

Part 3: Scenario-based questions

  1. A process named worker is consuming resources. Identify its PID and request graceful termination. What should you try only if it refuses to stop?

  2. You press Ctrl-Z to suspend a foreground command. Write commands to list the job, resume it in the background, and bring it back to the foreground.

  3. On a Debian-family distribution, you need to refresh repository metadata and install curl. On a Red Hat-family distribution, you need to search for and install curl. Give the commands for both families.

  4. You cannot connect to server.example using SSH. Give a logical diagnostic sequence that separates IP connectivity, DNS resolution, SSH service or port problems, and authentication problems.

  5. A system reports that a filesystem is almost full, but you do not know which directory is responsible. Which commands compare filesystem capacity with directory usage?

  6. A script returns “Permission denied.” List the checks you would make before deciding whether sudo is appropriate.

Answer key and explanations

Answers 1–8

  1. Answer: cd projects/app. A relative path starts at the current working directory. An absolute path begins at the root directory, such as /home/alex/projects/app. Use pwd to print the current working directory and confirm the result.

  2. Answer: ls -la. The -l option selects a long format, and -a includes names beginning with a dot. A wildcard is different: *.txt is expanded by the shell before ls receives it.

  3. Answer: the second option. Numeric permissions use read = 4, write = 2, and execute = 1. Therefore 7 is rwx, 5 is r-x, and 0 is ---. For a directory, execute means that a user may traverse it; read lists names, and write permits creating or removing entries when the appropriate directory permissions are present.

  4. Answer: the second option. Standard input, standard output, and standard error are the shell's conventional streams. A pipe, written with |, connects standard output from the command on the left to standard input of the command on the right.

  5. Answer: SIGTERM, commonly sent with kill -TERM PID. It requests a graceful shutdown and lets a program clean up. SIGKILL cannot be caught or handled, so use kill -KILL PID only after confirming the PID and trying a graceful signal.

  6. Answer: id. whoami prints the effective username, while id also shows the numeric user ID, primary group, and supplementary groups. Groups allow permissions to be shared without giving every user administrative access.

  7. Answer: the third option. A package manager uses package metadata and configured repositories to find software, resolve dependencies, install or remove packages, and track package state. A package file is an archive used for installation; an installed package is registered in the system's package database.

  8. Answer: getent hosts server.example. This asks the configured name-service system to resolve the hostname. A successful lookup does not prove that the host is reachable or that its SSH service accepts connections; those are separate tests.

Answers 9–14

  1. Example answer:

    mkdir reports
    cp summary.txt reports/
    cd reports
    pwd
    ls -la

    mkdir creates the directory, cp copies without removing the original, cd changes the current working directory, and pwd plus ls -la verify the result. Use mv when relocating or renaming, and use rm carefully because deletion normally does not place files in a recoverable desktop trash.

  2. Answer: *.log.

    find /var/log -name '*.log'

    The quoted pattern is interpreted by find, not expanded prematurely by the shell. The * wildcard matches any sequence of characters. Wildcards are shell pathname expansion, while a pattern used by grep is commonly a regular expression; these are related but not identical systems.

  3. Answer:

    grep 'ERROR' application.log | wc -l

    grep selects matching lines, the pipeline passes those lines to wc, and -l counts lines. For a fixed literal string, options such as grep -F can avoid regular-expression interpretation when that matters.

  4. Answer:

    ./build.sh > build.log
    ./build.sh >> build.log
    ./build.sh 2> build-errors.log

    > creates or replaces the output file, while >> appends. The descriptor 2 represents standard error; standard output is descriptor 1. A command can redirect both streams separately.

  5. Answer: the owner has read, write, and execute; the group has read and execute; others have no permissions. The numeric form is 750. For a regular file, execute permits running the file when its contents are a valid executable or script; it does not automatically mean the file can be modified.

  6. Answer: chmod u+x script.sh. The symbolic mode targets the user or owner class and adds execute permission. This is often safer than replacing the complete mode when existing group and other permissions should remain unchanged.

Answers 15–20

  1. Example answer:

    pgrep worker
    kill -TERM PID

    Replace PID with the confirmed process identifier. You can inspect more detail with ps aux. If the process still does not stop, check that the PID is correct and try kill -KILL PID only as a final measure. A service manager or parent process may restart a terminated process.

  2. Answer:

    jobs
    bg %1
    fg %1

    The job number may not be 1; use the number shown by jobs. Ctrl-Z suspends a foreground job, bg resumes it in the background, and fg returns it to the foreground. A process ID, or PID, identifies a process system-wide; a job number identifies a shell-managed job.

  3. Answer:

    # Debian family
    sudo apt update
    sudo apt install curl
    
    # Red Hat family
    sudo dnf search curl
    sudo dnf install curl

    apt update refreshes repository metadata; it does not upgrade every installed package. Package commands use configured repositories unless you explicitly install a local package file. Use sudo because installing system software changes protected system state, and review privileged commands before confirming them.

  4. Example diagnostic sequence:

    getent hosts server.example
    ping server.example
    ssh user@server.example
    ssh -p 2222 user@server.example

    First test DNS resolution with getent. If it resolves, test basic IP connectivity with ping, understanding that firewalls may block ping even when other traffic works. Then test SSH on the expected port. If the service responds but login fails, check the username, key, local key permissions, server account permissions, and authentication configuration. An SSH failure can result from DNS, routing, firewall rules, a stopped SSH service, a wrong port, or credentials; these are distinct problems.

  5. Answer:

    df -h
    du -sh /path/to/directory
    du -sh /path/to/directory/*

    df -h reports available and used space for mounted filesystems. du measures space attributed to directories and files. Compare the full mount point from df with directory totals from du. Check logs, temporary files, and package caches before removing anything, and do not delete unknown system files.

  6. Answer: inspect the script and its parent directories with ls -l and ls -ld; check whether the required execute permission is present; confirm ownership with ls -l; check identity and group membership with id; verify that the filesystem is not mounted with a restriction such as noexec; and check whether the interpreter named by the script exists. If a command inside the script is missing, inspect spelling, PATH, and whether the required package is installed. Use sudo only when the operation genuinely requires administrative access and you understand its effect.

Reference tables

Linux Command Recognition Reference

CommandPrimary purposeCommon option or patternQuiz concept tested
pwdPrint the current working directorypwdPath navigation
cdChange directorycd /path/to/directoryAbsolute and relative paths
lsList directory entriesls -laHidden files and metadata
cp, mv, rmCopy, move, or remove entriescp source destinationFile operations
grepSearch textgrep 'pattern' filePatterns and pipelines
ps, pgrepInspect processesps aux, pgrep namePIDs and process selection
killSend a signalkill -TERM PIDGraceful termination
df, duMeasure filesystem and directory usagedf -h, du -sh directoryStorage diagnosis
ip, ping, getent, sshInspect and test networkingip addr, ssh user@hostInterfaces, DNS, and remote access

Permission Representation Guide

PermissionSymbolic valueNumeric valueEffect on filesEffect on directories
Readr4Read contentsList names
Writew2Modify contentsCreate or remove entries, subject to directory access rules
Executex1Run the file when applicableTraverse or access entries by name
No permission-0No corresponding accessNo corresponding access

Permission strings contain three groups of three positions: user, group, and other. In rwxr-x---, the user has rwx, the group has r-x, and others have ---. Ownership can be changed with chown user:group file_or_directory and group ownership alone with chgrp group file_or_directory.

Package Manager Command Equivalents

TaskDebian-family commandRed Hat-family commandExpected result
Refresh repository metadatasudo apt updatesudo dnf makecacheRefresh available package information
Search packagesapt search termdnf search termFind matching package names or descriptions
Install softwaresudo apt install packagesudo dnf install packageInstall a package and dependencies
Remove softwaresudo apt remove packagesudo dnf remove packageRemove an installed package
Update installed softwaresudo apt upgradesudo dnf upgradeApply available package updates

Process Signal Overview

SignalTypical command formPurposeWhen to use it
SIGTERM (15)kill -TERM PIDRequests orderly terminationNormal first choice
SIGKILL (9)kill -KILL PIDForcibly ends a processLast resort after confirming the PID
SIGSTOPkill -STOP PIDSuspends a processWhen immediate suspension is required
SIGHUP (1)kill -HUP PIDOften requests configuration reload or indicates a terminal hangupOnly when the program documents this behavior

Review notes for missed questions

  • Questions 1, 2, 9, and 10: review absolute paths, relative paths, pwd, cd, ls, wildcards, find, and basic file operations.
  • Questions 3, 6, and 14: review user, group, and other permission classes; chmod, chown, chgrp; and directory execute permission.
  • Questions 4, 11, and 12: review standard input, standard output, standard error, redirection, append redirection, pipelines, grep, wc, cat, less, head, tail, sort, cut, and tee.
  • Questions 5, 15, and 16: review processes, PIDs, signals, foreground and background jobs, jobs, bg, fg, and process priority concepts such as nice values.
  • Questions 6, 17, and 20: review user and group accounts, root responsibilities, sudo, /etc/passwd, /etc/group, and identity commands such as whoami and id.
  • Questions 7 and 17: review APT, DNF, repositories, dependency resolution, local package files, and the difference between package metadata and installed package state.
  • Questions 8 and 18: review network interfaces and addresses with ip addr, connectivity with ping, DNS with getent hosts, SSH with ssh user@host, and common ports such as SSH 22, DNS 53, HTTP 80, and HTTPS 443.
  • Questions 19 and 20: review uname -a, distribution information such as /etc/os-release, mounted filesystems with findmnt or df, storage with df and du, memory with free -h, and uptime with uptime.

For further practice, continue with Linux Quiz 1, Linux Quiz 2, or Linux Quiz 4.