Q: You need to find all `.log` files modified in the last 7 days and copy them to an archive directory. What command do you use?
The most efficient command would be:
find and xargs or -exec.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Want to master this scenario in a live sandbox? The Linux Foundation's Certified System Administrator (LFCS) & SRE Track covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "In an interview, I explain my systematic Linux troubleshooting methodology using Brendan Gregg's USE method. The interviewer is testing: Familiarity with find and xargs or -exec.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Production Solution & Architecture
The most efficient command would be: find /path/to/search -name "*.log" -mtime -7 -type f -exec cp {} /path/to/archive/ \; Alternatively, for a large number of files (to avoid spawning multiple cp processes), use xargs: find /path/to/search -name "*.log" -mtime -7 -type f -print0 | xargs -0 -I {} cp {} /path/to/archive/ The -mtime -7 checks for files modified in less than 7 days, -type f restricts to files only, and -print0 with -0 handles filenames with spaces safely.
- Immediate Triage: The most efficient command would be:
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Issuing immediate kill -9 (SIGKILL) commands rather than allowing graceful termination via kill -15 (SIGTERM) when configuring need find files SIGKILL immediately halts execution without allowing processes to flush memory buffers, commit database transactions, or remove stale PID locks.
-
Overlooking file system inode exhaustion (df -i) when diagnosing 'No space left on device' errors when configuring need find files
Millions of small files or unrotated session tokens can exhaust available file system inodes even when standard disk storage (
df -h) shows ample free space. - Exhausting open file descriptor allocations (ulimit -n) under intensive concurrent socket connections when configuring need find files Reaching file descriptor exhaustion throws 'Too many open files' errors, preventing services from accepting new TCP client socket connections.
-
Permitting defunct zombie processes to accumulate without fixing parent process SIGCHLD waitpid reaping when configuring need find files
Zombie processes consume process table entries; accumulating zombies can exhaust the system maximum PID limit (
pid_max).