Linux · Shell interview questions

54 Linux · Shell questions from the System Administration bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.

Free to start: the 2-minute IT readiness check — six questions and a result.

Take the free IT readiness check

or take a mock interview set up for this area

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

Answer + AI explanation with Pro

2. Which command will search text for lines matching a pattern?

Junior
  1. A.grep
  2. B.cut -d: -f1 /etc/passwd
  3. C.sed
  4. D.awk

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

5. Which command will process and extract text by fields/columns?

Junior
  1. A.xargs
  2. B.wc -l file
  3. C.awk
  4. D.awk '{print $1}'

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

7. What does sed do?

Junior
  1. A.search text for lines matching a pattern
  2. B.perform stream text substitution/editing
  3. C.count the number of lines in a file
  4. D.process and extract text by fields/columns

Answer + AI explanation with Pro

8. Which command will perform stream text substitution/editing?

Junior
  1. A.head -n 20 file
  2. B.wc -l file
  3. C.sed
  4. D.find / -name '*.log' -mtime +7

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

11. Which term means: "redirect stderr to wherever stdout currently points"?

Mid
  1. A.2>&1
  2. B.$?
  3. C.| (pipe)
  4. D.trap

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

14. Which term means: "the exit code of the last command (0 = success)"?

Junior
  1. A.$?
  2. B.&& operator
  3. C.| (pipe)
  4. D.trap

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

17. Which term means: "append output to a file instead of overwriting it"?

Junior
  1. A.>> operator
  2. B.&& operator
  3. C.set -euo pipefail
  4. D.| (pipe)

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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)

Answer + AI explanation with Pro

20. Which command will extract the first colon-delimited field (usernames)?

Junior
  1. A.find / -name '*.log' -mtime +7
  2. B.wc -l file
  3. C.cut -d: -f1 /etc/passwd
  4. D.awk

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

22. What does sort | uniq -c do?

Junior
  1. A.show the first 20 lines of a file
  2. B.count occurrences of each unique line
  3. C.extract the first colon-delimited field (usernames)
  4. D.search text for lines matching a pattern

Answer + AI explanation with Pro

23. Which command will count occurrences of each unique line?

Junior
  1. A.sed -i 's/foo/bar/g' file
  2. B.wc -l file
  3. C.sort | uniq -c
  4. D.head -n 20 file

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

25. What does wc -l file do?

Junior
  1. A.process and extract text by fields/columns
  2. B.count the number of lines in a file
  3. C.build and run commands from standard input
  4. D.find .log files modified more than 7 days ago

Answer + AI explanation with Pro

26. Which command will count the number of lines in a file?

Junior
  1. A.sort | uniq -c
  2. B.head -n 20 file
  3. C.wc -l file
  4. D.cut -d: -f1 /etc/passwd

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

29. Which command will show the first 20 lines of a file?

Junior
  1. A.wc -l file
  2. B.awk
  3. C.head -n 20 file
  4. D.sed

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Start with a free readiness check

Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Linux · Shell question come with Pro.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers