Linux · Shell interview questions

54 real Linux · Shell questions from the System Administration bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What does grep do?

Junior
  1. A.search text for lines matching a pattern
  2. B.print the first whitespace-delimited field of each line
  3. C.count the number of lines in a file
  4. D.find .log files modified more than 7 days ago
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Junior
  1. A.grep — count occurrences of each unique line
  2. B.grep — process and extract text by fields/columns
  3. C.grep — print the first whitespace-delimited field of each line
  4. D.grep — search text for lines matching a pattern
Reveal the answer + AI explanation — free account

4. What does awk do?

Junior
  1. A.process and extract text by fields/columns
  2. B.print the first whitespace-delimited field of each line
  3. C.build and run commands from standard input
  4. D.find .log files modified more than 7 days ago
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Junior
  1. A.awk — extract the first colon-delimited field (usernames)
  2. B.awk — process and extract text by fields/columns
  3. C.awk — find .log files modified more than 7 days ago
  4. D.awk — count the number of lines in a file
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Junior
  1. A.sed — perform stream text substitution/editing
  2. B.sed — count the number of lines in a file
  3. C.sed — replace all 'foo' with 'bar' in-place
  4. D.sed — show the first 20 lines of a file
Reveal the answer + AI explanation — free account

10. What is 2>&1?

Mid
  1. A.the exit code of the last command (0 = success)
  2. B.append output to a file instead of overwriting it
  3. C.runs the next command only if the previous one succeeded
  4. D.redirect stderr to wherever stdout currently points
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Mid
  1. A.2>&1 — redirect stderr to wherever stdout currently points
  2. B.2>&1 — append output to a file instead of overwriting it
  3. C.2>&1 — runs the next command only if the previous one succeeded
  4. D.2>&1 — strict bash mode: exit on error, unset vars and pipe failures
Reveal the answer + AI explanation — free account

13. What is $??

Junior
  1. A.a bash builtin that runs code on a received signal (e.g. cleanup on EXIT)
  2. B.append output to a file instead of overwriting it
  3. C.the exit code of the last command (0 = success)
  4. D.sends the stdout of one command to the stdin of the next
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Junior
  1. A.$? — strict bash mode: exit on error, unset vars and pipe failures
  2. B.$? — redirect stderr to wherever stdout currently points
  3. C.$? — the exit code of the last command (0 = success)
  4. D.$? — runs the next command only if the previous one succeeded
Reveal the answer + AI explanation — free account

16. What is >> operator?

Junior
  1. A.the exit code of the last command (0 = success)
  2. B.a bash builtin that runs code on a received signal (e.g. cleanup on EXIT)
  3. C.sends the stdout of one command to the stdin of the next
  4. D.append output to a file instead of overwriting it
Reveal the answer + AI explanation — free account

18. Which statement is correct?

Junior
  1. A.>> operator — redirect stderr to wherever stdout currently points
  2. B.>> operator — the exit code of the last command (0 = success)
  3. C.>> operator — a bash builtin that runs code on a received signal (e.g. cleanup on EXIT)
  4. D.>> operator — append output to a file instead of overwriting it
Reveal the answer + AI explanation — free account

19. What does cut -d: -f1 /etc/passwd do?

Junior
  1. A.show the first 20 lines of a file
  2. B.perform stream text substitution/editing
  3. C.build and run commands from standard input
  4. D.extract the first colon-delimited field (usernames)
Reveal the answer + AI explanation — free account

21. Which statement is correct?

Junior
  1. A.cut -d: -f1 /etc/passwd — show the first 20 lines of a file
  2. B.cut -d: -f1 /etc/passwd — extract the first colon-delimited field (usernames)
  3. C.cut -d: -f1 /etc/passwd — count the number of lines in a file
  4. D.cut -d: -f1 /etc/passwd — perform stream text substitution/editing
Reveal the answer + AI explanation — free account

24. Which statement is correct?

Junior
  1. A.sort | uniq -c — process and extract text by fields/columns
  2. B.sort | uniq -c — count occurrences of each unique line
  3. C.sort | uniq -c — count the number of lines in a file
  4. D.sort | uniq -c — show the first 20 lines of a file
Reveal the answer + AI explanation — free account

27. Which statement is correct?

Junior
  1. A.wc -l file — process and extract text by fields/columns
  2. B.wc -l file — find .log files modified more than 7 days ago
  3. C.wc -l file — print the first whitespace-delimited field of each line
  4. D.wc -l file — count the number of lines in a file
Reveal the answer + AI explanation — free account

28. What does head -n 20 file do?

Junior
  1. A.show the first 20 lines of a file
  2. B.extract the first colon-delimited field (usernames)
  3. C.search text for lines matching a pattern
  4. D.build and run commands from standard input
Reveal the answer + AI explanation — free account

30. Which statement is correct?

Junior
  1. A.head -n 20 file — extract the first colon-delimited field (usernames)
  2. B.head -n 20 file — show the first 20 lines of a file
  3. C.head -n 20 file — print the first whitespace-delimited field of each line
  4. D.head -n 20 file — process and extract text by fields/columns
Reveal the answer + AI explanation — free account

Showing 30 of 54 Linux · Shell questions — the full set, with answers, explanations and an AI tutor on every question, is inside.

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Linux · Shell free