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
Your current working directory is
/home/alex. Which command changes to/home/alex/projects/appusing a relative path?cd /projects/appcd projects/apppwd projects/appmv projects/app
Which command displays hidden files, permissions, ownership, and file sizes in a long listing?
ls -rls -lals -dls -t
What does
chmod 750 deploy.shgrant?- 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.
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.
Which signal should normally be tried first when asking a process to terminate cleanly?
SIGKILLSIGSTOPSIGTERMSIGHUPin every situation
Which command displays the current user identity and supplementary groups?
idjobsdfuname
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.
Which command tests name resolution without opening an SSH session?
getent hosts server.examplechmod server.examplefree -h server.exampledu -sh server.example
Part 2: Command completion and short answers
Write commands that create a directory named
reports, copysummary.txtinto it, and then verify your location and files.Complete the command to find every file ending in
.logbelow/var/log:find /var/log -name '_____'.Write a command that finds lines containing
ERRORinapplication.logand counts those lines.Write commands that send normal output from
build.shtobuild.log, append later output to that file, and send error output tobuild-errors.log.Interpret
rwxr-x---for a regular file. Which permission classes have access, and what numeric mode represents it?Write a command that adds execute permission for the file's owner without changing other permission bits.
Part 3: Scenario-based questions
A process named
workeris consuming resources. Identify its PID and request graceful termination. What should you try only if it refuses to stop?You press
Ctrl-Zto suspend a foreground command. Write commands to list the job, resume it in the background, and bring it back to the foreground.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 installcurl. Give the commands for both families.You cannot connect to
server.exampleusing SSH. Give a logical diagnostic sequence that separates IP connectivity, DNS resolution, SSH service or port problems, and authentication problems.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?
A script returns “Permission denied.” List the checks you would make before deciding whether
sudois appropriate.
Answer key and explanations
Answers 1–8
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. Usepwdto print the current working directory and confirm the result.Answer:
ls -la. The-loption selects a long format, and-aincludes names beginning with a dot. A wildcard is different:*.txtis expanded by the shell beforelsreceives it.Answer: the second option. Numeric permissions use read = 4, write = 2, and execute = 1. Therefore 7 is
rwx, 5 isr-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.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.Answer:
SIGTERM, commonly sent withkill -TERM PID. It requests a graceful shutdown and lets a program clean up.SIGKILLcannot be caught or handled, so usekill -KILL PIDonly after confirming the PID and trying a graceful signal.Answer:
id.whoamiprints the effective username, whileidalso shows the numeric user ID, primary group, and supplementary groups. Groups allow permissions to be shared without giving every user administrative access.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.
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
Example answer:
mkdir reports cp summary.txt reports/ cd reports pwd ls -lamkdircreates the directory,cpcopies without removing the original,cdchanges the current working directory, andpwdplusls -laverify the result. Usemvwhen relocating or renaming, and usermcarefully because deletion normally does not place files in a recoverable desktop trash.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 bygrepis commonly a regular expression; these are related but not identical systems.Answer:
grep 'ERROR' application.log | wc -lgrepselects matching lines, the pipeline passes those lines towc, and-lcounts lines. For a fixed literal string, options such asgrep -Fcan avoid regular-expression interpretation when that matters.Answer:
./build.sh > build.log ./build.sh >> build.log ./build.sh 2> build-errors.log>creates or replaces the output file, while>>appends. The descriptor2represents standard error; standard output is descriptor1. A command can redirect both streams separately.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.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
Example answer:
pgrep worker kill -TERM PIDReplace
PIDwith the confirmed process identifier. You can inspect more detail withps aux. If the process still does not stop, check that the PID is correct and trykill -KILL PIDonly as a final measure. A service manager or parent process may restart a terminated process.Answer:
jobs bg %1 fg %1The job number may not be
1; use the number shown byjobs.Ctrl-Zsuspends a foreground job,bgresumes it in the background, andfgreturns it to the foreground. A process ID, or PID, identifies a process system-wide; a job number identifies a shell-managed job.Answer:
# Debian family sudo apt update sudo apt install curl # Red Hat family sudo dnf search curl sudo dnf install curlapt updaterefreshes repository metadata; it does not upgrade every installed package. Package commands use configured repositories unless you explicitly install a local package file. Usesudobecause installing system software changes protected system state, and review privileged commands before confirming them.Example diagnostic sequence:
getent hosts server.example ping server.example ssh user@server.example ssh -p 2222 user@server.exampleFirst test DNS resolution with
getent. If it resolves, test basic IP connectivity withping, 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.Answer:
df -h du -sh /path/to/directory du -sh /path/to/directory/*df -hreports available and used space for mounted filesystems.dumeasures space attributed to directories and files. Compare the full mount point fromdfwith directory totals fromdu. Check logs, temporary files, and package caches before removing anything, and do not delete unknown system files.Answer: inspect the script and its parent directories with
ls -landls -ld; check whether the required execute permission is present; confirm ownership withls -l; check identity and group membership withid; verify that the filesystem is not mounted with a restriction such asnoexec; 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. Usesudoonly when the operation genuinely requires administrative access and you understand its effect.
Reference tables
Linux Command Recognition Reference
| Command | Primary purpose | Common option or pattern | Quiz concept tested |
|---|---|---|---|
pwd | Print the current working directory | pwd | Path navigation |
cd | Change directory | cd /path/to/directory | Absolute and relative paths |
ls | List directory entries | ls -la | Hidden files and metadata |
cp, mv, rm | Copy, move, or remove entries | cp source destination | File operations |
grep | Search text | grep 'pattern' file | Patterns and pipelines |
ps, pgrep | Inspect processes | ps aux, pgrep name | PIDs and process selection |
kill | Send a signal | kill -TERM PID | Graceful termination |
df, du | Measure filesystem and directory usage | df -h, du -sh directory | Storage diagnosis |
ip, ping, getent, ssh | Inspect and test networking | ip addr, ssh user@host | Interfaces, DNS, and remote access |
Permission Representation Guide
| Permission | Symbolic value | Numeric value | Effect on files | Effect on directories |
|---|---|---|---|---|
| Read | r | 4 | Read contents | List names |
| Write | w | 2 | Modify contents | Create or remove entries, subject to directory access rules |
| Execute | x | 1 | Run the file when applicable | Traverse or access entries by name |
| No permission | - | 0 | No corresponding access | No 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
| Task | Debian-family command | Red Hat-family command | Expected result |
|---|---|---|---|
| Refresh repository metadata | sudo apt update | sudo dnf makecache | Refresh available package information |
| Search packages | apt search term | dnf search term | Find matching package names or descriptions |
| Install software | sudo apt install package | sudo dnf install package | Install a package and dependencies |
| Remove software | sudo apt remove package | sudo dnf remove package | Remove an installed package |
| Update installed software | sudo apt upgrade | sudo dnf upgrade | Apply available package updates |
Process Signal Overview
| Signal | Typical command form | Purpose | When to use it |
|---|---|---|---|
SIGTERM (15) | kill -TERM PID | Requests orderly termination | Normal first choice |
SIGKILL (9) | kill -KILL PID | Forcibly ends a process | Last resort after confirming the PID |
SIGSTOP | kill -STOP PID | Suspends a process | When immediate suspension is required |
SIGHUP (1) | kill -HUP PID | Often requests configuration reload or indicates a terminal hangup | Only 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, andtee. - 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 aswhoamiandid. - 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 withping, DNS withgetent hosts, SSH withssh 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 withfindmntordf, storage withdfanddu, memory withfree -h, and uptime withuptime.
For further practice, continue with Linux Quiz 1, Linux Quiz 2, or Linux Quiz 4.