Stage 3: Shell Warrior
Help learners master the Linux shell by understanding how to interact with the system, chain commands using pipes, and control input/output with redirection. This builds the foundation for automation and troubleshooting in interviews.
Hackbook Overview
1. What is the Shell?
- Interface between user and kernel.
- Common shells: Bash, Zsh, Ksh.
- Bash is the default on most Linux systems.
2. Environment Variables
- Store system and user settings.
- Examples:
$PATH,$HOME,$USER. - Commands:
echo $PATH,export VAR=value.
3. Pipes (|)
- Connect output of one command to input of another.
- Example:
ls -l | grep ".txt"→ lists only.txtfiles.
4. Redirection
- Output redirection:
>(overwrite),>>(append). - Input redirection:
<(read from file). - Example:
echo "Hello" > file.txt.
5. Why This Matters in Interviews
- Shows ability to combine commands for efficiency.
- Demonstrates understanding of system internals and data flow.
- Often tested in DevOps and SysAdmin interviews.
Hands‑On Practice
- Print your current shell:
echo $SHELL. - Add a new environment variable:
export GREETING="Hello Linux". - Use pipes:
ps aux | grep ssh. - Redirect output:
ls > files.txt. - Append output:
date >> files.txt. - Read input:
wc -l < files.txt.
Interview Question Bank
Conceptual
- Q1. What is the role of the shell in Linux?
A1. The shell is a command interpreter that lets users interact with the kernel by executing commands. - Q2. What are environment variables and why are they important?
A2. Environment variables store system and user settings, like$PATH, which defines where executables are searched. - Q3. What is the difference between
>and>>in redirection?
A3.>overwrites the file with new output, while>>appends output to the existing file.
Practical
- Q4. How do you find your current shell?
A4. Runecho $SHELLor check/etc/passwdfor the default shell. - Q5. How do you search for processes related to Apache using pipes?
A5. Runps aux | grep apache. - Q6. How do you redirect the output of a command into a file?
A6. Use>:ls > output.txt.
Scenario‑Based
- Q7. You want to count the number of
.logfiles in/var/log. How would you do it?
A7.ls /var/log/*.log | wc -l. - Q8. A command produces too much output. How do you view it page by page?
A8. Pipe it intoless:dmesg | less. - Q9. You need to append the current date to a log file. What command do you use?
A9.date >> logfile.txt.
Behavioral Based
- Q10. Tell me about a time you used pipes or redirection to solve a problem.
A10. Example: “During troubleshooting, I piped logs throughgrepto quickly isolate error messages, saving time during a production issue.”
Cheatsheet (Quick Notes)
- Shell Types: Bash, Zsh, Ksh.
- Environment Variables:
$PATH,$HOME,$USER. - Pipes:
command1 | command2. - Redirection:
>overwrite,>>append,<input. - Useful Commands:
echo $SHELL,export VAR=value,ps aux | grep.

Updated on Dec 21, 2025