MauryaHub PYQ Practice

System Commands · Quiz 1 · May 2026

System Commands · Quiz 1 · May 2026

← Course papers · Start practice / exam

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 2 NAT · 3.0 marks

A Linux-like file system uses **index nodes (inodes)** to manage files. A newly formatted volume has 10,000 free inodes. A user performs the following sequential actions: 1. A directory named
Source diagram or notation
is created. 2. Inside
Source diagram or notation
, a script creates a single large data file named
Source diagram or notation
. 3. The script then successfully creates
Source diagram or notation
**hard links** to
Source diagram or notation
within the same directory, each with a unique name. 4. Finally, the script successfully creates
Source diagram or notation
**symbolic (soft) links**, each pointing to
Source diagram or notation
. Assume each symbolic link occupies its own inode and hard links do not allocate new inodes. Assuming no other processes are writing to the volume, what is the total number of **free** **inodes** remaining on the volume after these actions are completed?

Published solution

**1. Count new objects:** The directory needs one inode and dataset.bin needs one inode. The 1,500 hard links are additional directory entries referring to the same file inode, so they consume no new inodes. **2. Count symbolic links:** Each of 500 symbolic links has its own inode. Total used is \(1+1+500=502\). **3. Subtract from the free pool:** \(10000-502=9498\) free inodes remain. **Answer: 9498.**

Report a correction for Q2

Question 3 MSQ · 3.0 marks

A system administrator is configuring a shared project directory. The requirements for three specific system objects are defined as follows: 1.
Source diagram or notation
: The owner can only read and write to it. Members of the group can only read it. Everyone else has no access. 2.
Source diagram or notation
: Anyone on the system can read and execute it, but only the owner can modify it. 3.
Source diagram or notation
: It is a directory. The owner and group members have read, write, and execute permissions on it. External users ("others") have execute permission only, allowing them to access known files without listing the directory contents. Which of the following lines matches the correct
Source diagram or notation
output for these objects?
6406537023159.Source diagram or notation
6406537023160.Source diagram or notation
6406537023161.Source diagram or notation
6406537023162.Source diagram or notation
6406537023163.Source diagram or notation

Published solution

**1. Translate each permission requirement:** archive.tar needs rw-r----- (640); deploy.sh needs rwxr-xr-x (755); logs needs rwxrwx--x (771). **2. Include the object type:** Regular files begin with −, whereas the logs directory begins with d. These produce the lines shown in A, B and D. **Answer: A, B, D — A, B and D — modes 640, 755 and directory 771.** A: **Correct:** −rw-r----- gives owner read/write, group read and no others access. B: **Correct:** −rwxr-xr-x gives everyone read/execute and only the owner write. C: **Incorrect:** drwxrwxr-x also lets others read/list the directory. D: **Correct:** drwxrwx--x gives others search/execute without read permission. E: **Incorrect:** −rw-r--r-- wrongly allows others to read archive.tar.

Report a correction for Q3

Question 4 MSQ · 3.0 marks

A file named
Source diagram or notation
contains the following four raw text lines:
Source diagram or notation
An administrator uses different variations of regular expressions to extract specific log entries. Which of the following statements is/are **TRUE** regarding the execution and matching behavior of these commands?
6406537023184.
The command
Source diagram or notation
will successfully match and output the line
Source diagram or notation
.
6406537023185.
To make standard
Source diagram or notation
match the same lines as
Source diagram or notation
, the pattern can be rewritten as:
Source diagram or notation
.
6406537023186.
The command
Source diagram or notation
will match
Source diagram or notation
and
Source diagram or notation
, but will exclude
Source diagram or notation
.
6406537023187.
The command
Source diagram or notation
will output nothing because word boundary assertions (
Source diagram or notation
) are only supported in Extended Regular Expressions (
Source diagram or notation
).

Published solution

**1. Distinguish BRE and ERE:** Ordinary grep uses basic regex: unescaped parentheses and | are literal. In GNU BRE, backslash-prefixed parentheses group, and a backslash-prefixed bar supplies alternation; grep -E uses the unescaped forms. **2. Apply the word boundary:** In error_404\b, the boundary requires the next character to be non-word or the end of the line. It accepts system_error_404 and error_404 but rejects system_error_4040. GNU grep supports this boundary in both modes. **Answer: B, C — BRE rewrite and boundary-matching statements B and C.** **Convention note:** The escaped alternation and word-boundary syntax here use GNU grep extensions. A: **Incorrect:** The basic pattern searches for literal parentheses and |, so it does not match the displayed line. B: **Correct:** Escaping the parentheses and alternation bar supplies the equivalent BRE grouping and alternatives. C: **Correct:** The final \b excludes a following digit. D: **Incorrect:** GNU basic grep supports \b too; the command prints the two matching lines.

Report a correction for Q4

Question 5 MSQ · 3.0 marks

You have created a file named
Source diagram or notation
that contains the following filenames:
Source diagram or notation
You want to extract only the lines that contain
Source diagram or notation
and
Source diagram or notation
(but not
Source diagram or notation
or
Source diagram or notation
). Which of the following grep commands will correctly achieve this?
6406537023188.Source diagram or notation
6406537023189.Source diagram or notation
6406537023190.Source diagram or notation
6406537023191.Source diagram or notation

Published solution

**1. Require the full filename:** Use ^ and $ to anchor both ends, and \. for the literal extension separator. **2. Choose exactly one digit:** In ERE, (1|2) and [12] each match a single 1 or 2. Therefore A and B match file1.txt and file2.txt without accepting file10.txt or file20.txt. **Answer: A, B — Commands A and B.** A: **Correct:** Grouped alternation confines the filename to exactly file1.txt or file2.txt. B: **Correct:** The character class selects exactly one digit before the literal extension. C: **Incorrect:** The prefix alternatives also match file10.txt and file20.txt. D: **Incorrect:** Ungrouped alternation leaves the first branch as the prefix ^file1, which also matches file10.txt.

Report a correction for Q5

Question 6 MCQ · 3.0 marks

A system directory contains the following list of files: •
Source diagram or notation
•
Source diagram or notation
•
Source diagram or notation
•
Source diagram or notation
•
Source diagram or notation
An administrator wants to process a specific subset of these files using the following command:
Source diagram or notation
Which of the following statements correctly describes which files are matched by this command and why?
6406537023164.
It matches only
Source diagram or notation
because the
Source diagram or notation
wildcard acts as a quantifier requiring exactly two digits total.
6406537023165.
It matches
Source diagram or notation
and
Source diagram or notation
because the
Source diagram or notation
wildcard matches any sequence of characters (including empty strings) following the first two digits.
6406537023166.
It matches
Source diagram or notation
,
Source diagram or notation
, and
Source diagram or notation
because wildcards match files based only on the prefix before the first bracket.
6406537023167.
It matches
Source diagram or notation
,
Source diagram or notation
, and
Source diagram or notation
because
Source diagram or notation
matches any single alphanumeric character.

Published solution

**1. Parse the shell glob:** backup_[0-9][0-9]*.tar requires the backup_ prefix, two digit characters, then any additional characters, and the .tar suffix. **2. Test the candidates:** backup_2025.tar and backup_26.tar match. The .log files have the wrong suffix, and backup_v2.tar fails the first digit requirement. **Answer: B — backup_2025.tar and backup_26.tar.** A: **Incorrect:** The glob * is not a repetition operator for the preceding digit class. B: **Correct:** Both filenames meet the two-digit prefix and .tar suffix requirements. C: **Incorrect:** backup_2026.log has the wrong extension. D: **Incorrect:** [0-9] matches a digit, not the letter v.

Report a correction for Q6

Question 7 MCQ · 3.0 marks

A DevOps engineer is configuring secure, passwordless SSH access from a local administration workstation to a remote Linux cloud server. Which of the following operations is correctly described regarding the placement and management of the keys?
6406537023168.
The private key must be appended to the
Source diagram or notation
file on the remote server so it can decrypt incoming client challenges.
6406537023169.
Both the public and private keys must be copied to the remote server's
Source diagram or notation
directory to establish trusted mutual identity.
6406537023170.
The public key must be securely transferred and appended to the
Source diagram or notation
file on the remote server, while the private key remains exclusively on the local workstation.
6406537023171.
The private key is automatically deleted from the local workstation by the
Source diagram or notation
utility once the matching public key is uploaded to the destination server.

Published solution

**1. Place the public credential:** Append the client’s public key to the target remote account’s ~/.ssh/authorized_keys. **2. Retain the secret locally:** The client uses its private key to sign authentication data. The server checks that signature using the public key; the private key need not be transferred. **Answer: C — Public key in remote authorized_keys; private key stays local.** A: **Incorrect:** authorized_keys contains public keys, not private keys. B: **Incorrect:** Server host keys and user authentication keys serve different roles. C: **Correct:** The public key is authorized remotely while the client retains its private key. D: **Incorrect:** ssh-copy-id installs the public key and does not delete the private key.

Report a correction for Q7

Question 8 MCQ · 3.0 marks

Match the following Vi/Vim and Emacs commands to their correct functionality. **Vi / Vim Commands**
Source diagram or notation
**Emacs Commands** Note: Here,
Source diagram or notation
means the
Source diagram or notation
key and
Source diagram or notation
means the
Source diagram or notation
(Meta) key.
Source diagram or notation
Which of the following option combinations is correct?
6406537023172.
**Vi:** 1-C, 2-D, 3-B, 4-A **| Emacs:** 1-B, 2-D, 3-A, 4-C
6406537023173.
**Vi:** 1-C, 2-D, 3-A, 4-B **| Emacs:** 1-B, 2-A, 3-D, 4-C
6406537023174.
**Vi:** 1-D, 2-C, 3-B, 4-A **| Emacs:** 1-C, 2-D, 3-A, 4-B
6406537023175.
**Vi:** 1-D, 2-C, 3-A, 4-B **| Emacs:** 1-C, 2-A, 3-D, 4-B

Published solution

**1. Match Vim operations:** dd deletes the current line (C); u undoes the last change (D); p puts register contents (B); / begins a forward search (A). **2. Match Emacs operations:** C-x C-s saves (B); C-s searches incrementally forward (D); C-w kills the region (A); C-y yanks killed text (C). **Answer: A — Vim 1-C,2-D,3-B,4-A; Emacs 1-B,2-D,3-A,4-C.** A: **Correct:** Every Vim and Emacs mapping is correct. B: **Incorrect:** It swaps Vim paste/search and Emacs search/kill. C: **Incorrect:** It swaps Vim delete/undo and misassigns Emacs save/yank. D: **Incorrect:** Several delete, undo, search and paste mappings are reversed.

Report a correction for Q8

Question 9 MCQ · 3.0 marks

A system administrator writes a maintenance script named
Source diagram or notation
. They attempt to run the script with the following redirection setup in the terminal:
Source diagram or notation
What is the operational outcome of executing this specific command?
6406537023176.
Both standard output (
Source diagram or notation
) and standard error (
Source diagram or notation
) are appended to
Source diagram or notation
because both redirections use the same filename.
6406537023177.
The command results in a syntax error because the same file cannot be used for multiple redirections in a single command.
6406537023178.
Both
Source diagram or notation
and
Source diagram or notation
are redirected to
Source diagram or notation
, but the file is opened independently for each file descriptor. As a result, output from the two streams may interleave, overwrite portions of each other, or appear in an unpredictable order.
6406537023179.
The shell detects that both streams target the same file and automatically treats the command as
Source diagram or notation
.

Published solution

**1. Process the redirections:** 2> debug.log opens the file for stderr; > debug.log opens it again for stdout. Both use truncating output redirection. **2. Track the file offsets:** The two opens have independent offsets rather than sharing a duplicated descriptor. Writes from the streams can overwrite one another or mix, depending on the program’s writes and buffering. **Answer: C — Independent stdout/stderr opens can overwrite or mix output.** A: **Incorrect:** > truncates; it does not mean append. B: **Incorrect:** Separate descriptors may legally redirect to the same pathname. C: **Correct:** Independent opens create the stated overwrite/mixing risk. D: **Incorrect:** The shell does not automatically replace separate opens with descriptor duplication.

Report a correction for Q9

Question 10 MCQ · 3.0 marks

You want to perform an automated network diagnostics sequence with the following constraints: 1. Run a primary connection test script
Source diagram or notation
. 2. **If and only if it fails**, run an intensive route tracing script
Source diagram or notation
. 3. From the output of
Source diagram or notation
, extract **only** the lines containing the word
Source diagram or notation
. 4. Save those filtered lines to a file named
Source diagram or notation
. Which command combination is correct?
6406537023180.Source diagram or notation
6406537023181.Source diagram or notation
6406537023182.Source diagram or notation
6406537023183.Source diagram or notation

Published solution

**1. Select the failure branch:** A || B executes B only if A has a nonzero exit status, so || gives the required fallback. **2. Filter and save only fallback output:** In A, the grouped fallback runs ./trace_route.sh, pipes its stdout to grep "DROP", and redirects those matched lines to network_errors.log. **Answer: A — ./ping_server.sh || { ./trace_route.sh | grep "DROP" > network_errors.log; }.** **Convention note:** For the literal whole-word requirement on arbitrary output, use grep -w "DROP". The offered correct command uses substring matching, so it would also match DROPPED; A is the intended combination. A: **Correct:** It combines failure-only execution with filtering and file output. B: **Incorrect:** && runs the fallback on success rather than failure. C: **Incorrect:** It writes the entire tracer output without filtering. D: **Incorrect:** It filters but does not save the result to the required file.

Report a correction for Q10

Question 11 MCQ · 3.0 marks

Which of the following commands will print lines 8 to 15 (inclusive) from the top of a file named
Source diagram or notation
?
6406537023196.Source diagram or notation
6406537023197.Source diagram or notation
6406537023198.Source diagram or notation
6406537023199.Source diagram or notation

Published solution

**1. Retain the prefix:** head -15 keeps original lines 1–15. **2. Retain its suffix:** The last \(15-8+1=8\) lines of that prefix are original lines 8–15, so tail -8 selects exactly the requested range. **Answer: A — cat system.log | head -15 | tail -8.** A: **Correct:** It takes the last eight lines of the first fifteen. B: **Incorrect:** It selects from the file’s final fifteen lines, not necessarily its beginning. C: **Incorrect:** It retains only original lines 1–8. D: **Incorrect:** It prints the final eight lines of the entire file.

Report a correction for Q11

Question 12 MCQ · 3.0 marks

Source diagram or notation
The above command is used to
6406537023200.
retrieve information about a domain name, such as its server and IP address.
6406537023201.
looks up the number of pings to the domain name "google.com".
6406537023202.
Gets the DNS of the domain on google.com
6406537023203.
none of these

Published solution

**1. Identify the tool:** nslookup queries DNS. For nslookup google.com it reports the responding DNS server and the resolved domain-address information, subject to the DNS response. **Answer: A — retrieve information about a domain name, such as its server and IP address..** A: **Correct:** This describes the DNS lookup output. B: **Incorrect:** It does not count or send ICMP ping requests. C: **Incorrect:** The command queries configured DNS for google.com; it does not use google.com as a DNS server. D: **Incorrect:** The first option correctly describes the lookup.

Report a correction for Q12

Question 13 MCQ · 3.0 marks

An operator attempts to run a critical update sequence on a production server using the following two independent commands: • **Command 1:**
Source diagram or notation
• **Command 2:**
Source diagram or notation
After running both commands, the engineer notices that
Source diagram or notation
**did not execute**, but
Source diagram or notation
**did execute**. Based on the short-circuit behavior of shell operators, what can be definitively concluded about the exit statuses of the initial scripts (
Source diagram or notation
and
Source diagram or notation
)?
6406537023204.Source diagram or notation
exited with a success status (0), and
Source diagram or notation
exited with a failure status (non-zero).
6406537023205.Source diagram or notation
exited with a failure status (non-zero), and
Source diagram or notation
exited with a success status (0).
6406537023206.
Both
Source diagram or notation
and
Source diagram or notation
exited with a success status (0).
6406537023207.
Both
Source diagram or notation
and
Source diagram or notation
exited with a failure status (non-zero).

Published solution

**1. Apply &&:** ./verify_env.sh && ./run_update.sh skips the second script only when verify_env.sh fails, returning nonzero. **2. Apply ||:** ./check_disk.sh || ./clean_tmp.sh runs clean_tmp.sh when check_disk.sh fails. Thus both initial scripts returned nonzero exit statuses. **Answer: D — Both initial scripts failed with nonzero status.** A: **Incorrect:** A successful verification would have run the update. B: **Incorrect:** A successful disk check would have skipped cleanup. C: **Incorrect:** Both observed branches indicate failure, not success. D: **Correct:** Both initial statuses must be nonzero.

Report a correction for Q13

Question 14 MSQ · 4.0 marks

**File:**
Source diagram or notation
Note: Answer this question only based on the file contents given below.
Source diagram or notation
Contents:
Source diagram or notation
You want to find all lines that **start exactly with**
Source diagram or notation
**(lowercase only)** and **end with a 4-** **digit port number that specifically begins with**
Source diagram or notation
(i.e., ports in the range
Source diagram or notation
to
Source diagram or notation
). Which of the following commands will correctly print all and only the required lines?
6406537023192.Source diagram or notation
6406537023193.Source diagram or notation
6406537023194.Source diagram or notation
6406537023195.Source diagram or notation

Published solution

**1. Build the exact pattern:** The required form is lowercase node_port=, followed by 80 and exactly two digits, then end of line. **2. Compare regex forms:** B uses ERE repetition [0-9]{2}; D writes the two digit classes explicitly. Both select node_port=8080, node_port=8085 and node_port=8081 from the supplied file. **Answer: B, D — B and D — exactly lowercase node_port=80 followed by two digits.** A: **Incorrect:** .* accepts short, long and nondigit suffixes, including 80a0. B: **Correct:** The anchors and exactly two trailing digits enforce the required form. C: **Incorrect:** -i also accepts the uppercase NODE_PORT=8080 line. D: **Correct:** Two consecutive digit classes enforce the same exact length without -E.

Report a correction for Q14

Question 15 MCQ · 4.0 marks

Consider the following standard IPv4 address class ranges: • Class A:
Source diagram or notation
• Class B:
Source diagram or notation
• Class C:
Source diagram or notation
• Loopback:
Source diagram or notation
A file named
Source diagram or notation
contains a list of various IP addresses. You want to extract **only the lines** **containing Class B IP addresses** based strictly on their first octet value (ranging from 128 to 191). Which of the following commands will correctly filter and print these lines?
6406537023208.Source diagram or notation
6406537023209.Source diagram or notation
6406537023210.Source diagram or notation
6406537023211.Source diagram or notation

Published solution

**1. Split the first-octet range:** 128–191 is the union of 128–129, 130–189 and 190–191. **2. Encode those intervals:** The alternatives 12[8-9], 1[3-8][0-9], and 19[0-1], anchored at the start and followed by a literal dot, implement exactly that first-octet range. **Answer: A — grep -E '^(12[8-9]|1[3-8][0-9]|19[0-1])\.' ips.txt.** **Convention note:** The task assumes valid IPv4 address lines and asks only for first-octet filtering; this expression is not a full IPv4 validator. A: **Correct:** Its three alternatives cover precisely 128 through 191. B: **Incorrect:** It matches only the two endpoints 128 and 191. C: **Incorrect:** A bracket expression is a character class, not an integer range. D: **Incorrect:** The extra digit classes in the middle alternative do not encode 130–189.

Report a correction for Q15

Question 16 MSQ · 3.0 marks

Assume you are in your home directory
Source diagram or notation
, and the current directory structure is:
Source diagram or notation
You always start executing each question from the base directory
Source diagram or notation
. Note: Both questions are to be answered independently, based solely on the directory structure provided above. Based on the above data, answer the given subquestions.
You want to perform the following operations: 1. Create a new nested directory path named
Source diagram or notation
directly inside
Source diagram or notation
. 2. Create an empty file named
Source diagram or notation
inside that new
Source diagram or notation
directory. 3. Inside the
Source diagram or notation
directory, create nine new empty test files named
Source diagram or notation
,
Source diagram or notation
, ... up to
Source diagram or notation
. Which of the following command sets will perform all the above operations correctly?
6406537023212.Source diagram or notation
6406537023213.Source diagram or notation
6406537023214.Source diagram or notation
6406537023215.Source diagram or notation

Published solution

**1. Create the missing parents:** mkdir -p src/utils/helpers creates both utils and helpers. touch then creates string_utils.py at the required location. **2. Resolve paths and expansions:** In A, ../../../test from src/utils/helpers reaches /home/developer/test, and test_{1..9}.py expands into nine names. C uses valid relative paths and an explicit comma-list brace expansion. **Answer: A, C — Command sets A and C.** A: **Correct:** It creates the hierarchy, returns to the sibling test directory, and expands nine filenames. B: **Incorrect:** Without -p, mkdir cannot create helpers when src/utils is absent. C: **Correct:** All paths are correct and the brace list contains the nine requested filenames. D: **Incorrect:** test_1..9.py is a single literal filename, not a Bash brace expansion.

Report a correction for Q16

Question 17 MCQ · 3.0 marks

Assume you are in your home directory
Source diagram or notation
, and the current directory structure is:
Source diagram or notation
You always start executing each question from the base directory
Source diagram or notation
. Note: Both questions are to be answered independently, based solely on the directory structure provided above. Based on the above data, answer the given subquestions.
An engineer executes the following command sequence in their terminal, starting from
Source diagram or notation
:
Source diagram or notation
Which of the following statements correctly describes the final outcome and system state after these commands are run?
6406537023216.
The
Source diagram or notation
file is moved to
Source diagram or notation
, the empty
Source diagram or notation
directory is successfully deleted, and
Source diagram or notation
lists
Source diagram or notation
.
6406537023217.
The command sequence throws a syntax error on the first line because
Source diagram or notation
must be specified as an absolute path.
6406537023218.
A copy of
Source diagram or notation
is created in
Source diagram or notation
, but the
Source diagram or notation
command fails with an error because the
Source diagram or notation
directory still contains the original file.
6406537023219.
The entire
Source diagram or notation
directory and its contents are forcefully removed, leaving ouild ae completely empty.

Published solution

**1. Apply cp:** cp test/test_core.py build/ creates a copy in build and leaves the original inside test. **2. Apply rmdir and ls:** rmdir test fails because the directory is not empty. The separate next command ls build still runs and lists test_core.py. **Answer: C — Copy created; rmdir fails because test remains nonempty.** A: **Incorrect:** cp copies rather than moves, leaving test nonempty. B: **Incorrect:** Relative destination paths are valid. C: **Correct:** It correctly describes the copy, failed directory removal and resulting build content. D: **Incorrect:** rmdir does not recursively or forcibly delete nonempty directories.

Report a correction for Q17