LearnFrenzy
Sign in Take a free test

Operating Systems · Topic 10 of 11

Linux Commands and Shell: questions with answers

Files and permissions (chmod, umask, setuid, sticky bit), processes and signals, pipes and redirection, grep, sort, uniq, cut, awk, sed and tr, quoting, exit statuses, environment variables, cron and system tools.

Questions
45
Timed sets
3
Answers run or computed
24
Your accuracy
–

What this topic covers

8 subtopics
  • Text tools13
  • Shell7
  • Files6
  • Permissions6
  • System5
  • Pipes and redirection4
  • Processes3
  • Users1
  • Beginner 15
  • Intermediate 15
  • Advanced 15

About this topic

Linux questions appear in IT-services technical rounds, DevOps and backend interviews, and in day-to-day work on servers. The pipelines and shell snippets here were run in bash to produce their answers (output words are shown separated by single spaces), and permission strings were computed from the numeric modes.

Free preview

Sample questions

Try each one first, then open the answer for the explanation and why the other options are wrong.

Question 1 Permissions Beginner Practice Answer computed

After chmod 755 deploy.sh, what does ls -l show as the permission string?

-rwxr--r--
-rwxr-xr-x
-rwxrwxrwx
-rw-r--r--
Show answer and explanation
Correct answer B

Explanation

Each digit is r = 4, w = 2, x = 1 for owner, group and others: 7 = rwx, 5 = r-x. A typical mode for scripts and programs.

Why the other options are wrong

  • AThat is 744.
  • CThat is 777.
  • DThat is 644.
Question 2 Text tools Intermediate Practice Answer computed

What does this pipeline print?

printf 'b\na\nb\nc\nb\na\n' | sort | uniq -c | sort -rn | head -1
1 c
2 a
3 b
3 a
Show answer and explanation
Correct answer C

Explanation

sort groups equal lines, uniq -c counts each group, sort -rn puts the biggest count first, head -1 keeps the top line. This is the classic "most frequent line" idiom (e.g. top IP addresses in an access log). uniq only merges adjacent lines, which is why sort comes first.

Why the other options are wrong

  • ALeast frequent.
  • Bb appears 3 times.
  • Da appears twice.
Question 3 Permissions Advanced Practice Answer computed

/usr/bin/passwd has mode 4755. What does ls -l show, and why does it need that bit?

-rwsr-xr-x – setuid makes it run with its owner's (root's) privileges, so ordinary users can update /etc/shadow
drwsr-xr-x – it is a directory
-rwxr-xr-x – the 4 is ignored
-rwxr-xr-t – the sticky bit protects the file
Show answer and explanation
Correct answer A

Explanation

The s replaces the owner's x. Setuid programs are prime attack targets, so they must be small and careful.

Why the other options are wrong

  • BIt is a file.
  • CThe 4 sets setuid.
  • Dt is the sticky bit (1).
42 more questions in the timed setsSame format as the samples, with a timer, a question palette and a full review at the end.
Start practising

Operating Systems

All 11 topics

Topics, levels and full mocks
  1. 01 OS Basics and System Calls45 questions · 3 levels
  2. 02 Processes, Threads and fork()45 questions · 3 levels
  3. 03 CPU Scheduling Algorithms45 questions · 3 levels
  4. 04 Process Synchronization and Semaphores45 questions · 3 levels
  5. 05 Deadlocks and Banker's Algorithm45 questions · 3 levels
  6. 06 Memory Management and Paging45 questions · 3 levels
  7. 07 Virtual Memory and Page Replacement45 questions · 3 levels
  8. 08 File Systems and Disk Scheduling45 questions · 3 levels
  9. 09 Threads and Concurrency in Code45 questions · 3 levels
  10. 10 Linux Commands and Shell45 questions · 3 levels
  11. 11 GATE-Style OS Questions (MSQ & NAT)45 questions · 3 levels

Search LearnFrenzy

Esc

Quick links