Interview Q&A / Linux & Shell

INTERVIEW Q&A · 63 QUESTIONS

Linux & Shell interview questions

Permissions, processes, pipes and the commands you are expected to know cold.

  1. How do you search for text and files in Linux using grep and find?

    grep searches inside files for lines matching a pattern, for example grep -rn "error" logs/. find searches the directory tree for files by name, type, size or age, for example find . -name "*.log" -mtime -1. They are often combined to search text inside a chosen set of files.

    BeginnerIn-depth2 min read
  2. What do the grep options -i, -v, -c, -n and -w do?

    -i ignores case, -v inverts the match to show non-matching lines, -c prints only a count of matching lines, -n adds line numbers and -w matches whole words only. They combine, so grep -ivn error file works.

    BeginnerQuick answer1 min read
  3. When do you need grep -E, and what is the difference from basic grep patterns?

    Basic grep treats +, ?, | and () as ordinary characters unless escaped. grep -E (extended regex) gives them their regex meaning, so grep -E 'cat|dog' matches either word. Use -F when you want a plain fixed string with no regex at all.

    IntermediateQuick answer1 min read