Review practical Linux fundamentals: memory and swap interpretation, safe directory enumeration, process-versus-thread trade-offs, filesystem links, and option-safe file deletion. Also explain responsible recovery steps after an accidental recursive delete.
# Linux Host and Filesystem Fundamentals
### Clarifying Questions to Ask
- Which Linux distribution and shell should be assumed?
- Are privileged commands allowed, or should the answer work as an ordinary user?
- Is the system local, containerized, or running under an orchestration platform?
### Part 1: Inspect Memory and Explain Swap
How would you inspect memory usage on a Linux host? Explain what swap is, why it exists, and why low “free” memory or nonzero swap use is not automatically evidence of a problem.
**Candidate hint:** Separate process memory, reclaimable cache, memory pressure, and historical swap placement.
#### What This Part Should Cover
- Useful commands and fields rather than one unexplained number
- Available memory, cache, swap, and pressure interpretation
- Limits of a single snapshot
### Part 2: Working Directory and Listing Without `ls`
Which command prints the current working directory? Give at least two safe ways to enumerate entries in the current directory without using `ls`, including hidden entries where practical.
**Candidate hint:** Be explicit about recursion, dotfiles, quoting, and unusual filenames.
#### What This Part Should Cover
- `pwd` semantics
- Shell expansion or `find`-based alternatives and their caveats
- Filename-safe output when results feed another command
### Part 3: Threads and Processes
Compare a Linux process with a thread. Discuss address spaces, resources, scheduling, communication, isolation, and failure implications.
**Candidate hint:** Avoid saying that threads are not scheduled entities; focus on what is shared and what is private.
#### What This Part Should Cover
- Shared versus isolated state
- Context, communication, synchronization, and fault boundaries
- Practical performance trade-offs without absolute claims
### Part 4: Symbolic and Hard Links
Explain the difference between a symbolic link and a hard link. Cover inode relationships, filesystem boundaries, directories, deletion of the target name, and how common tools display them.
**Candidate hint:** Ask what directory entry each link points to and what keeps file data alive.
#### What This Part Should Cover
- Path indirection versus another name for one inode
- Lifetime and broken-link behavior
- Cross-filesystem and directory restrictions
### Part 5: Delete a File Named `-rf`
A regular file in the current directory is literally named `-rf`. How can you delete that exact file without it being interpreted as command options? Explain why the command is safe.
**Candidate hint:** Either terminate option parsing or make the operand stop beginning with a hyphen.
#### What This Part Should Cover
- A correctly quoted, exact operand
- `--` or an explicit relative path
- Awareness that quoting alone does not change a leading hyphen into a non-option
### Part 6: Recover After an Accidental Recursive Delete
Suppose a recursive removal deleted the current directory's contents. Is there a general shell command that restores those files? Explain what deletion changes and give a responsible immediate response and recovery order.
**Candidate hint:** Distinguish unlinking names from securely erasing blocks, but do not promise that unallocated data is recoverable.
#### What This Part Should Cover
- No universal undo and why continued writes reduce recovery chances
- Backups, snapshots, version control, and still-open file descriptors
- Filesystem-specific recovery as a last resort, not a guarantee
### What a Strong Answer Covers
- Commands paired with an explanation of what they measure or modify
- Safe handling of filenames and destructive operations
- Kernel and filesystem concepts connected to practical troubleshooting
- Appropriate caveats across distributions, filesystems, and runtime environments
### Follow-up Questions
1. Why can a process be killed by a memory limit while the host still reports available memory?
2. How would you pass arbitrary filenames safely from `find` to another command?
3. Why can an open file continue consuming disk after its pathname is deleted?
4. How do bind mounts differ from symbolic links?
Quick Answer: Review practical Linux fundamentals: memory and swap interpretation, safe directory enumeration, process-versus-thread trade-offs, filesystem links, and option-safe file deletion. Also explain responsible recovery steps after an accidental recursive delete.
Which Linux distribution and shell should be assumed?
Are privileged commands allowed, or should the answer work as an ordinary user?
Is the system local, containerized, or running under an orchestration platform?
Part 1: Inspect Memory and Explain Swap
How would you inspect memory usage on a Linux host? Explain what swap is, why it exists, and why low “free” memory or nonzero swap use is not automatically evidence of a problem.
Candidate hint: Separate process memory, reclaimable cache, memory pressure, and historical swap placement.
What This Part Should Cover Guidance
Useful commands and fields rather than one unexplained number
Available memory, cache, swap, and pressure interpretation
Limits of a single snapshot
Part 2: Working Directory and Listing Without ls
Which command prints the current working directory? Give at least two safe ways to enumerate entries in the current directory without using ls, including hidden entries where practical.
Candidate hint: Be explicit about recursion, dotfiles, quoting, and unusual filenames.
What This Part Should Cover Guidance
pwd
semantics
Shell expansion or
find
-based alternatives and their caveats
Filename-safe output when results feed another command
Part 3: Threads and Processes
Compare a Linux process with a thread. Discuss address spaces, resources, scheduling, communication, isolation, and failure implications.
Candidate hint: Avoid saying that threads are not scheduled entities; focus on what is shared and what is private.
What This Part Should Cover Guidance
Shared versus isolated state
Context, communication, synchronization, and fault boundaries
Practical performance trade-offs without absolute claims
Part 4: Symbolic and Hard Links
Explain the difference between a symbolic link and a hard link. Cover inode relationships, filesystem boundaries, directories, deletion of the target name, and how common tools display them.
Candidate hint: Ask what directory entry each link points to and what keeps file data alive.
What This Part Should Cover Guidance
Path indirection versus another name for one inode
Lifetime and broken-link behavior
Cross-filesystem and directory restrictions
Part 5: Delete a File Named -rf
A regular file in the current directory is literally named -rf. How can you delete that exact file without it being interpreted as command options? Explain why the command is safe.
Candidate hint: Either terminate option parsing or make the operand stop beginning with a hyphen.
What This Part Should Cover Guidance
A correctly quoted, exact operand
--
or an explicit relative path
Awareness that quoting alone does not change a leading hyphen into a non-option
Part 6: Recover After an Accidental Recursive Delete
Suppose a recursive removal deleted the current directory's contents. Is there a general shell command that restores those files? Explain what deletion changes and give a responsible immediate response and recovery order.
Candidate hint: Distinguish unlinking names from securely erasing blocks, but do not promise that unallocated data is recoverable.
What This Part Should Cover Guidance
No universal undo and why continued writes reduce recovery chances
Backups, snapshots, version control, and still-open file descriptors
Filesystem-specific recovery as a last resort, not a guarantee
What a Strong Answer Covers Guidance
Commands paired with an explanation of what they measure or modify
Safe handling of filenames and destructive operations
Kernel and filesystem concepts connected to practical troubleshooting
Appropriate caveats across distributions, filesystems, and runtime environments
Follow-up Questions Guidance
Why can a process be killed by a memory limit while the host still reports available memory?
How would you pass arbitrary filenames safely from
find
to another command?
Why can an open file continue consuming disk after its pathname is deleted?