Linux Command Line interview questions

21 questions from the Linux Command Line Fundamentals course, each with the correct answer and an explanation. Try to answer before you open the answer.

Module 1: Getting Started

1. A prompt ending in `#` instead of `$` usually means:

  1. A syntax error occurred
  2. The terminal is frozen
  3. You are logged in as root
  4. The shell is in read-only mode
Show answer

Answer: You are logged in as root

`#` is the traditional prompt symbol for the root/superuser account.

Lesson: The Terminal & Shell

Module 2: Navigation

2. Which path is absolute?

  1. reports/2026.csv
  2. ../config
  3. config/app.yml
  4. /var/log/syslog
Show answer

Answer: /var/log/syslog

Only paths starting with `/` are absolute; the others depend on the current directory.

Lesson: Absolute & Relative Paths

Module 3: File Operations

3. Which command lets you watch a log file update live?

  1. tail -f log.txt
  2. cat log.txt
  3. head log.txt
  4. wc log.txt
Show answer

Answer: tail -f log.txt

`tail -f` keeps the file open and prints new lines as they're appended.

Lesson: Viewing File Contents

4. Which command extracts backup.tar.gz?

  1. tar -xzf backup.tar.gz
  2. tar -czf backup.tar.gz
  3. tar -tzf backup.tar.gz
  4. gzip -c backup.tar.gz
Show answer

Answer: tar -xzf backup.tar.gz

`x` extracts, `z` handles gzip and `f` names the file.

Lesson: Finding Files & Archives (find, tar)

Module 4: Permissions

5. What does `chmod 644 file` set?

  1. rwxrwxrwx
  2. rw-r--r--
  3. r--r--r--
  4. ---rw-rw-
Show answer

Answer: rw-r--r--

6=rw-, 4=r--, 4=r-- for owner, group, other respectively.

Lesson: chmod & chown

Module 5: Text Processing

6. What does `sed 's/foo/bar/g'` do?

  1. Replaces only the first 'foo' per line
  2. Deletes lines containing 'foo'
  3. Replaces every 'foo' with 'bar' on each line
  4. Renames the file foo to bar
Show answer

Answer: Replaces every 'foo' with 'bar' on each line

The `g` flag makes the substitution global — all matches per line, not just the first.

Lesson: sed, awk & Piping

Module 6: Processes

7. Which signal cannot be caught or ignored by a process?

  1. SIGTERM
  2. SIGINT
  3. SIGUSR1
  4. SIGKILL
Show answer

Answer: SIGKILL

SIGKILL (signal 9) is handled by the kernel directly and always terminates the process.

Lesson: Jobs & Signals

Module 7: Package Management

8. Which package manager is standard on Ubuntu?

  1. apt
  2. dnf
  3. pacman
  4. zypper
Show answer

Answer: apt

Ubuntu is Debian-based and uses apt; dnf is for Fedora/RHEL, pacman for Arch.

Lesson: yum & dnf

Module 9: Environment

9. If two directories in PATH both have a program called `foo`, which one runs?

  1. Both run together
  2. The one found in the first matching directory
  3. Linux picks randomly
  4. The one with the shortest name
Show answer

Answer: The one found in the first matching directory

The shell searches PATH directories in order and stops at the first match.

Lesson: The PATH Variable

Module 10: Redirection & Pipes

10. What does the `|` operator do?

  1. Runs two commands in parallel
  2. Comments out the rest of the line
  3. Sends one command's output as the next command's input
  4. Creates a hard link
Show answer

Answer: Sends one command's output as the next command's input

That's exactly what a pipe does — connect stdout to the next command's stdin.

Lesson: Pipes & xargs

Module 11: Shell Scripting

11. In `[ $count -le 3 ]`, what does `-le` mean?

  1. less than
  2. not equal
  3. greater than
  4. less than or equal to
Show answer

Answer: less than or equal to

`-le` is bash's numeric "less than or equal to" test operator.

Lesson: Loops in Bash

Module 12: Networking & Remote Access

12. Which command copies a file to a remote server over SSH?

  1. scp
  2. ssh
  3. ping
  4. cat
Show answer

Answer: scp

scp (secure copy) transfers files using the SSH protocol.

Lesson: scp & Checking Connectivity

Module 13: System Administration

13. Which tool is used to run a script automatically every night at a fixed time?

  1. systemctl
  2. cron
  3. scp
  4. grep
Show answer

Answer: cron

cron is Linux's built-in job scheduler for recurring tasks.

Lesson: systemd & cron

14. Which command shows your current directory?

  1. ls
  2. cd
  3. pwd
  4. whoami
Show answer

Answer: pwd

pwd prints the working directory.

Lesson: systemd & cron

15. What does chmod 755 file set?

  1. rw-r--r--
  2. rwxrwxrwx
  3. r--r--r--
  4. rwxr-xr-x
Show answer

Answer: rwxr-xr-x

7 = rwx, 5 = r-x.

Lesson: systemd & cron

16. Which command follows a log file live?

  1. tail -f
  2. cat
  3. head
  4. wc
Show answer

Answer: tail -f

tail -f streams new lines as they are written.

Lesson: systemd & cron

17. What does `command > /dev/null 2>&1` do?

  1. Appends output to a file
  2. Discards stdout and stderr
  3. Runs in background
  4. Shows only errors
Show answer

Answer: Discards stdout and stderr

/dev/null swallows everything redirected to it.

Lesson: systemd & cron

18. Which signal cannot be caught or ignored?

  1. SIGTERM
  2. SIGINT
  3. SIGKILL
  4. SIGHUP
Show answer

Answer: SIGKILL

SIGKILL always terminates the process.

Lesson: systemd & cron

19. How do you install a package on Ubuntu?

  1. dnf get name
  2. pacman -Q name
  3. brew add name
  4. sudo apt install name
Show answer

Answer: sudo apt install name

apt is the Debian and Ubuntu package manager.

Lesson: systemd & cron

20. What does PATH do?

  1. Lists directories searched for commands
  2. Stores your home directory
  3. Lists open files
  4. Sets the prompt
Show answer

Answer: Lists directories searched for commands

The shell searches PATH entries in order.

Lesson: systemd & cron

21. Which tool schedules a recurring job?

  1. scp
  2. cron
  3. grep
  4. tar
Show answer

Answer: cron

crontab entries define time fields and commands.

Lesson: systemd & cron

← Back to the course