Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.
16 / 16 published solutions
Question 227 MCQ · 3.0 marks
Consider the fundamental difference between a hard link and a symbolic link. Which statement
best describes this difference?
6406534365141.
A hard link contains a copy of the original file's data, while a symbolic link does
not.
6406534365142.
A hard link is essentially another name for the same file data (inode), while a
symbolic link is a separate file containing the path to the original file.
6406534365143.
Hard links can cross filesystem boundaries, whereas symbolic links cannot.
6406534365144.
Hard links are exclusively used for pointing to directories, while symbolic links
can only point to regular files.
Published solution
**1. Compare what is stored:** A hard link is another directory entry for the same inode and data. A symbolic link is a separate object storing a target pathname.
**2. Apply the consequences:** Hard links do not copy file contents and normally cannot span filesystems. Symbolic links can name targets across filesystems and can point to directories.
**Answer: B — A hard link is essentially another name for the same file data (inode), while a .**
A: **Incorrect:** Hard links share existing data rather than copying it.
B: **Correct:** It correctly states shared identity versus a stored pathname.
C: **Incorrect:** This reverses the cross-filesystem distinction.
D: **Incorrect:** Hard links are generally restricted for directories; symbolic links can target directories or regular files.
**1. Select the prefix:** head -n 7 config.txt prints the first seven lines.
**2. Select the suffix:** tail -n 3 config.txt prints the final three lines. These are the two commands in A.
**Answer: A — head -n 7 config.txt and tail -n 3 config.txt.**
A: **Correct:** head and tail implement the two requested selections.
B: **Incorrect:** These are not valid cat first/last selection options.
C: **Incorrect:** less is a pager; the listed invocations do not implement the two bounded outputs.
D: **Incorrect:** The proposed display options are not the standard text-selection commands.
**1. Match the assigned ports:** SSH uses 22 (C), HTTP uses 80 (A), SMTP uses 25 (B), and HTTPS uses 443 (D).
**Answer: B — 1-C, 2-A, 3-B, 4-D.**
A: **Incorrect:** It mismatches SSH, HTTP and SMTP.
B: **Correct:** All four port-service mappings agree.
C: **Incorrect:** Each mapping assigns the wrong service.
D: **Incorrect:** It assigns the wrong service to each port.
**1. Start with reachability:** An SSH timeout can arise before authentication because of a disconnected or unreachable host. ping 192.168.1.50 provides an initial basic network probe.
**2. Interpret cautiously:** A reply supports host reachability; no reply is not conclusive because ICMP may be filtered. If needed, next check routing, firewalls and the SSH port.
**Answer: B — Check basic reachability with ping 192.168.1.50.**
A: **Incorrect:** Changing text editors does not repair a network timeout.
B: **Correct:** It is a simple first reachability check.
C: **Incorrect:** A crashed SSH service is only one possibility and has not been established.
D: **Incorrect:** There is no evidence that SSH is listening on a web port.
**1. Perform the Vim edit:** 1G moves to the first line, dd removes that whole line, and :wq saves and exits.
**2. Perform the nano edit:** Alt+\ moves to the file beginning; Ctrl+K cuts the current line. Ctrl+O, Enter saves, then Ctrl+X exits.
**Answer: A — Vim 1G, dd, :wq; nano beginning, cut line, save, exit.**
A: **Correct:** Both editors navigate to the first line, remove it and save before exiting.
B: **Incorrect:** D does not remove the whole line including its newline, and the nano sequence is incorrect.
C: **Incorrect:** x deletes a character rather than an entire line, and the nano sequence is incorrect.
D: **Incorrect:** The listed quit-without-saving operations discard the requested edit.
**1. Connect the streams:** In command1 | command2, the shell connects command1’s standard output to command2’s standard input.
**2. Distinguish execution control:** A pipe carries data; it does not mean “run only if the first command succeeds” or “run only if data appears.”
**Answer: D — stdout of command1 becomes stdin of command2.**
A: **Incorrect:** Sequential execution is the role of a list separator, not the defining pipe behaviour.
B: **Incorrect:** A plain pipe does not redirect stderr.
C: **Incorrect:** The second command starts even if the first produces no data.
D: **Correct:** It correctly identifies stdout-to-stdin data flow.
**1. Require verification success:** && starts create_report only after verify_data returns zero.
**2. Save only the report output:** > final_report.txt belongs to create_report and overwrites its output file when that branch runs. On verification failure the report command and its redirection are skipped.
**Answer: C — verify_data && create_report > final_report.txt.**
A: **Incorrect:** ; runs the report regardless of verification success.
B: **Incorrect:** || runs the report after failure.
C: **Correct:** It gates creation on success and overwrites the requested output file.
D: **Incorrect:** A pipe supplies data and does not condition execution on a successful status.
**1. Separate the producer streams:** generate_raw_data 2> raw_data_errors.log captures only the producer’s stderr with truncation.
**2. Pipe the remaining stdout:** | process_stream sends raw data into the processor. Its stdout remains on the terminal because it is not redirected.
**Answer: A — generate_raw_data 2> raw_data_errors.log | process_stream.**
A: **Correct:** It logs the producer’s stderr while piping its stdout into processing.
B: **Incorrect:** It logs the processor’s stderr rather than the producer’s.
C: **Incorrect:** It redirects stdout into a file named process_stream instead of running a pipeline.
D: **Incorrect:** |& combines producer stderr with the data stream, rather than separately logging it.
Lines that contain "A" followed by any character, then "Z" anywhere on the
line.
6406534365174.
Lines that start with "A", have zero or more of any character (except newline)
in between, and end with "Z".
6406534365175.
Lines that contain either "A" or "Z" at the very beginning or very end of the
line.
6406534365176.
Lines that consist only of the characters "A" and "Z" with nothing in between.
Published solution
**1. Read the anchors:** ^A requires A at the start and Z$ requires Z at the end.
**2. Read the middle:** .* means zero or more arbitrary non-newline characters within the line. Consequently AZ, ABZ and A123Z all match.
**Answer: B — Starts with A, ends with Z, with any intervening characters.**
A: **Incorrect:** The anchors require the whole line boundary positions, and * allows more than one middle character.
B: **Correct:** It correctly describes the two anchors and variable-length middle.
C: **Incorrect:** No alternation appears in the expression.
D: **Incorrect:** AZ matches, but longer strings also match.
**1. Anchor the prefix:** ^ap requires lowercase ap at the start of a line.
**2. Apply case-sensitive matching:** It prints apple, apricot and apply, but not banana or Apollo.
**Answer: D — grep '^ap' data.txt.**
A: **Incorrect:** ap* means a followed by zero or more p characters anywhere, so banana can match its a.
B: **Incorrect:** $ap puts an end anchor before ap rather than anchoring the beginning.
C: **Incorrect:** ap$ requires ap at the end of a line.
D: **Correct:** ^ap directly expresses the requested starting prefix.
**1. Parse the ERE:** ^(Task|Project) ID: [0-9]+ requires Task or Project at the start, then the literal text and at least one digit.
**2. Apply output redirection:** grep prints matching complete lines; > results.txt creates or truncates the destination and saves those lines.
**Answer: A — Matching Task/Project ID lines overwrite results.txt.**
**Convention note:** There is no final $ anchor, so additional text after the matched digits is allowed.
A: **Correct:** It describes the anchored alternatives, digit repetition and overwrite.
B: **Incorrect:** The match is anchored and + accepts more than one digit.
C: **Incorrect:** > overwrites rather than appends.
D: **Incorrect:** The alternatives allow either prefix; they do not require both.
**1. Open the destination:** With ordinary shell settings, > file1 opens an existing file with truncation, or creates a new file if it is absent and the directory permits it.
**2. Distinguish append:** >> is the append operator. Standard > does not request interactive confirmation.
**Answer: B, C — Existing content is overwritten; a missing file is created.**
**Convention note:** This assumes successful permissions and ordinary clobber settings; set -C/noclobber can prevent overwriting an existing regular file.
A: **Incorrect:** Appending is the role of >>, not >.
B: **Correct:** An existing destination is normally truncated before execution.
C: **Correct:** A missing destination can be created.
D: **Incorrect:** The shell normally performs this redirection without confirmation.
**1. Decode ls -lai:** ls lists entries; -l requests long format, -a includes dot-prefixed entries, and -i adds inode numbers.
**2. Interpret /usr/bin:** This standard directory primarily contains executable commands available to users. Thus A, D and E are correct.
**Answer: A, D, E — A, D and E.**
A: **Correct:** ls is the directory-listing utility.
B: **Incorrect:** -l requests long format rather than short format.
C: **Incorrect:** -a includes hidden entries rather than suppressing them.
D: **Correct:** -i displays each entry’s inode number.
E: **Correct:** /usr/bin primarily holds user commands/executables.
**1. Read the BRE interval:** [[:digit:]]\{3\} matches a run of three digits. The escaped braces are the correct basic-regex repetition syntax.
**2. Apply substring matching:** With no ^ or $ anchors, 123,789,2345 and 111 all contain a three-digit run. The mixed strings 45a and b01 do not. Four lines match.
**Answer: 4.**
**1. Create and copy with absolute paths:** A creates /home/user/Temp/Backup, copies Documents/report.txt there, and lists the destination.
**2. Resolve C’s relative paths:** After cd Temp, mkdir Backup creates the same directory. ../Documents/report.txt refers back to the home-level Documents directory, so its copy and listing are also correct.
**Answer: A, C — Command sets A and C.**
A: **Correct:** Its absolute paths consistently identify the required source and destination.
B: **Incorrect:** mk dir, copy and list are not the standard commands shown by the task.
C: **Correct:** Its relative paths resolve correctly from Temp.
D: **Incorrect:** newdir and move are not the required commands, and moving would not preserve the original as requested.
**1. Encode the target mode:** Owner rw gives \(4+2=6\); group r gives 4; others none gives 0. Thus chmod 640 is correct.
**2. Check symbolic notation:** chmod u=rw,g=r,o= sets exactly the same permission categories. Both produce −rw-r-----.
**Answer: B, D — chmod 640 or chmod u=rw,g=r,o=; −rw-r-----.**
A: **Incorrect:** 750 grants owner/group execute permission and differs from the request.
B: **Correct:** 640 produces exactly rw-r-----.
C: **Incorrect:** 740 also grants owner execute permission, regardless of the claimed displayed string.
D: **Correct:** The symbolic assignments exactly set owner rw, group r and others none.