MauryaHub PYQ Practice

System Commands · Quiz 1 · Jan 2025

System Commands · Quiz 1 · Jan 2025

← 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.

14 / 15 published solutions

Question 241 MCQ · 3.0 marks

Source diagram or notation
6406533774690.Source diagram or notation
6406533774691.Source diagram or notation
6406533774692.Source diagram or notation
6406533774693.Source diagram or notation

Published solution

**1. Track the first directory change:** mkdir creates app and app/public. cd app succeeds, so the right side of || is skipped and the shell remains in /home/user1/app. **2. Finish the sequence:** touch creates index.html in app. cd .. returns to /home/user1. mv changes the file location, not the shell’s working directory. **Answer: B — /home/user1.** A: **Incorrect:** The || branch entering public is skipped. B: **Correct:** cd .. returns the shell to its original home directory. C: **Incorrect:** This was the location before cd ... D: **Incorrect:** The commands never enter a root-level /app directory.

Report a correction for Q241

Question 242 MCQ · 3.0 marks

Source diagram or notation
6406533774694.
9
6406533774695.
6
6406533774696.
3
6406533774697.
0

Published solution

**1. Expand both brace groups:** .file-{1..3}{a..c} produces \(3\times3=9\) filenames, such as .file-1a and .file-3c. **2. Apply default ls visibility:** Every name starts with a dot, so plain ls hides all nine. Its output has zero lines, and wc -l prints 0. **Answer: D — 0.** A: **Incorrect:** Nine files exist, but plain ls does not show these hidden names. B: **Incorrect:** The expansion creates nine objects, none visible to plain ls. C: **Incorrect:** There are two independent three-element brace groups, and all results are hidden. D: **Correct:** No names appear in the plain ls output.

Report a correction for Q242

Question 243 MCQ · 3.0 marks

Source diagram or notation
6406533774702.Source diagram or notation
6406533774703.Source diagram or notation
6406533774704.Source diagram or notation
6406533774705.Source diagram or notation

Published solution

**1. Follow ln without -s:** example_a.txt is a hard link to example.txt, so both names identify the same inode. **2. Follow ln -s:** example_b.txt is a separate symbolic-link inode that stores the target’s pathname. It does not share the regular file’s inode. **Answer: C — example.txt and example_a.txt have the same inode.** A: **Incorrect:** A hard link shares the original inode. B: **Incorrect:** The symlink has its own inode. C: **Correct:** The original and its hard link have the same inode. D: **Incorrect:** The third statement correctly describes the hard link.

Report a correction for Q243

Question 244 MCQ · 3.0 marks

Source diagram or notation
6406533774706.Source diagram or notation
6406533774707.Source diagram or notation
6406533774708.Source diagram or notation
6406533774709.Source diagram or notation

Published solution

**1. Translate full access:** Read, write and execute contribute \(4+2+1=7\). Both owner and group therefore need digit 7. **2. Deny others:** Others need digit 0, giving chmod 770 script.sh and the permission string −rwxrwx---. **Answer: B — chmod 770 script.sh.** A: **Incorrect:** 600 gives only owner read/write and no group rights. B: **Correct:** 770 gives owner/group rwx and others no permission. C: **Incorrect:** 740 gives group only read. D: **Incorrect:** 750 gives group read/execute but not write.

Report a correction for Q244

Question 245 MCQ · 3.0 marks

Which of the following shell variables can be used to get the return code of the last command?
6406533774710.Source diagram or notation
6406533774711.Source diagram or notation
6406533774712.Source diagram or notation
6406533774713.Source diagram or notation

Published solution

**1. Read the special parameter:** $? expands to the exit status of the most recently completed foreground pipeline/command. Read it before another command replaces that status. **Answer: B — $?.** A: **Incorrect:** $! is the most recent background process ID. B: **Correct:** $? contains the previous command/pipeline exit status. C: **Incorrect:** $1 is the first positional argument. D: **Incorrect:** $0 is the shell or script name.

Report a correction for Q245

Question 246 MCQ · 4.0 marks

Source diagram or notation
6406533774698.Source diagram or notation
6406533774699.Source diagram or notation
6406533774700.Source diagram or notation
6406533774701.Source diagram or notation

Published solution

**1. Create the input:** echo Hello > hello.txt writes Hello and a newline. **2. Process cat’s operands:** cat emits hello.txt first, writing Hello through stdout’s truncating open of output.txt. The missing /blah.txt then produces a diagnostic through stderr, opened with append mode on that same pathname. **3. Read the result:** The file contains Hello followed by the missing-file diagnostic, as shown in B. **Answer: B — Hello, followed by cat: /blah.txt: No such file or directory.** **Convention note:** This assumes /blah.txt does not exist, as the answer choices intend, and the standard cat diagnostic locale. A: **Incorrect:** It omits the successful read of hello.txt. B: **Correct:** It includes normal output followed by the appended error message. C: **Incorrect:** It omits the error from the missing absolute-path operand. D: **Incorrect:** cat reads the valid first operand before diagnosing the missing second one.

Report a correction for Q246

Question 247 MCQ · 4.0 marks

Source diagram or notation
6406533774714.Source diagram or notation
6406533774715.Source diagram or notation
6406533774716.Source diagram or notation
6406533774717.Source diagram or notation

Published solution

**1. Identify the intended filter:** find with -not -name is intended to exclude .txt names, and wc -l counts its output. **2. Check the actual command:** The offered A is not an exact nonrecursive regular-file count: find descends into subdirectories and also prints directories, while its unquoted *.txt may expand before find runs. **3. Write a precise version:** For ordinary filenames, use find /home/user1 -maxdepth 1 -type f ! -name "*.txt" | wc -l. This limits the search to regular files directly in the requested directory. **Answer: A — A is intended; add -maxdepth 1 -type f and quote "*.txt".** **Convention note:** No offered command exactly implements the stated current-directory regular-file count. The source-key choice A is retained as the intended option, with its limitations explicitly corrected. A: **Correct:** Intended answer only: it negates the .txt name test and counts results, but requires the corrections explained above. B: **Incorrect:** It selects .txt names instead of excluding them. C: **Incorrect:** It does not count the results and its BRE pattern does not correctly express the desired extension filter. D: **Incorrect:** It selects matching text suffixes rather than counting non-.txt files.

Report a correction for Q247

Question 248 MSQ · 3.0 marks

Source diagram or notation
6406533774718.Source diagram or notation
6406533774719.Source diagram or notation
6406533774720.Source diagram or notation
6406533774721.Source diagram or notation

Published solution

**1. Extract the numbers:** egrep -o [[:digit:]]+ outputs each digit run from the supplied JSON. Its sequence values are 26803,8629,27799,4749. **2. Select the maximum:** sort -nr orders them descending, so head -n 1 gives 27799. Alternatively sort -n orders ascending, so tail -n 1 gives the same maximum. **Answer: A, C — Pipelines A and C — 27799.** **Convention note:** This extraction works for the supplied JSON because its only digit runs are the requested values. A structural JSON parser is preferable for arbitrary JSON containing other numbers. A: **Correct:** Descending numeric order followed by head selects the maximum. B: **Incorrect:** Ascending order followed by head selects the minimum 4749. C: **Correct:** Ascending numeric order followed by tail selects the maximum. D: **Incorrect:** Descending order followed by tail selects the minimum 4749.

Report a correction for Q248

Question 249 MSQ · 3.0 marks

Source diagram or notation
6406533774726.Source diagram or notation
6406533774727.Source diagram or notation
6406533774728.Source diagram or notation
6406533774729.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q249

Question 250 MSQ · 4.0 marks

Source diagram or notation
6406533774722.Source diagram or notation
6406533774723.Source diagram or notation
6406533774724.Source diagram or notation
6406533774725.Source diagram or notation

Published solution

**1. Specify the whole code:** A valid six-digit colour code consists of # followed by exactly six hexadecimal digits, with ^ and $ anchoring the line. A correct ERE is ^#[0-9A-Fa-f]{6}$. **2. Group into pairs:** Equivalently, ^#([0-9A-Fa-f][0-9A-Fa-f]){3}$ matches three two-digit groups. These are the intended structures of A and C. **Answer: A, C — A and C, after removing the PDF’s extraneous escaping.** **Convention note:** The PDF visibly prefixes parentheses and braces with extra backslashes while calling the syntax extended. Taken literally in grep -E these are not grouping/repetition operators. A and C are the intended answers only after normalizing that formatting; use the exact EREs shown above. A: **Correct:** Intended correct structure: one hash followed by exactly six hexadecimal digits. B: **Incorrect:** A + permits arbitrary positive lengths rather than exactly six digits. C: **Correct:** Intended correct structure: exactly three pairs of hexadecimal digits. D: **Incorrect:** It omits the required initial hash and full-line boundaries.

Report a correction for Q250

Question 251 MCQ · 4.0 marks

Source diagram or notationSource diagram or notation
6406533774730.
The total number of files in the directory
6406533774731.
The total number of blocks used by the files and directories
6406533774732.
The total size of the directory in bytes
6406533774733.
The total number of links to the directory

Published solution

**1. Distinguish allocation from logical size:** The total line in ls -l sums the disk allocation reported for the listed entries, expressed in the configured block units. **2. Interpret total 8:** It is a block-allocation total, not a count of files, links, bytes of directory content, or recursive directory-tree size. **Answer: B — Allocated block total for the listed entries.** **Convention note:** GNU ls commonly uses 1 KiB display blocks by default; environment variables and options can change that unit. The total is not a recursive sum of directory contents. A: **Incorrect:** The listing has two named files, whereas the total measures allocation. B: **Correct:** It represents the listed entries’ allocated disk blocks in ls’s chosen unit. C: **Incorrect:** The individual logical byte sizes are separate fields. D: **Incorrect:** Link counts appear on each long-format entry.

Report a correction for Q251

Question 252 MCQ · 3.0 marks

Source diagram or notationSource diagram or notation
6406533774734.Source diagram or notation
6406533774735.Source diagram or notation
6406533774736.Source diagram or notation
6406533774737.Source diagram or notation

Published solution

**1. Read the initial group rights:** script.sh has −rwxr-xr--, so the group can read and execute but cannot write. **2. Add only the missing right:** chmod g+w script.sh grants group write while preserving the other permission bits, giving −rwxrwxr--. **Answer: A — chmod g+w script.sh.** A: **Correct:** g+w adds the missing group write permission. B: **Incorrect:** The group already has execute, and this adds no write permission. C: **Incorrect:** g-w removes write rather than granting it. D: **Incorrect:** 700 removes all group permissions.

Report a correction for Q252

Question 253 MCQ · 3.0 marks

Source diagram or notationSource diagram or notation
6406533774738.
96 blocks
6406533774739.
96 bytes
6406533774740.
96 kilobytes
6406533774741.
96 bits

Published solution

**1. Locate the size field:** In −rw-r--r-- 1 admin work 96 Jan 16 07:21 example.txt, the number 96 after owner/group is the logical file length. **2. Identify the unit:** Standard ls -l without a human-readable size option shows that regular-file length in bytes. Hence example.txt is 96 bytes. **Answer: B — 96 bytes.** A: **Incorrect:** Allocated block totals are separate from this logical size field. B: **Correct:** The long-listing size field is 96 bytes. C: **Incorrect:** No -h or other scaling option is specified. D: **Incorrect:** The size field is in bytes rather than bits.

Report a correction for Q253

Question 254 MCQ · 3.0 marks

Source diagram or notationSource diagram or notation
6406533774742.Source diagram or notation
6406533774743.Source diagram or notation
6406533774744.Source diagram or notation
6406533774745.Source diagram or notation

Published solution

**1. Interpret tail:** tail selects the end of a file. The -n 10 option requests ten lines, so the command prints the last ten lines of example.txt, or the entire file if it has fewer than ten. **Answer: D — The last ten lines of example.txt.** A: **Incorrect:** -n counts lines, not characters, and tail selects the end. B: **Incorrect:** The first ten lines would be selected by head. C: **Incorrect:** The character-counting option would be -c, not -n. D: **Correct:** It correctly describes the selected suffix.

Report a correction for Q254

Question 255 MSQ · 4.0 marks

Source diagram or notationSource diagram or notation
6406533774746.Source diagram or notation
6406533774747.Source diagram or notation
6406533774748.Source diagram or notation
6406533774749.Source diagram or notation

Published solution

**1. Split the original mode:** script.sh has owner rwx, group r-x and others r--. **2. Apply each claim:** Every category has read permission; the group also has execute. Others lack execute, and the group lacks write. Therefore only B and C are true. **Answer: B, C — All users can read; group users can execute.** **Convention note:** Use the original listing: the separate preceding question’s chmod operation is not applied here. Assume the required directory access and ordinary permission model. A: **Incorrect:** Others do not have execute permission. B: **Correct:** All three permission categories contain r. C: **Correct:** The group field is r-x. D: **Incorrect:** The group field lacks w.

Report a correction for Q255