30 Essential Linux Interview Questions Every Tester Should Know
This article compiles 30 practical Linux interview questions covering basic commands, file handling, permissions, disk usage, process management, monitoring tools, networking utilities, log analysis, text processing, and real‑world troubleshooting scenarios, each illustrated with concrete command examples and tester‑focused use cases.
1. Basic Concepts and File Operations (8 questions)
Commonly asked commands include ls -la to list detailed file info, cd to change directories, pwd to show the current path, mkdir to create directories, rm -rf for recursive deletion, cp and mv for copying and moving, cat and less for viewing files, and tail -f for real‑time log monitoring. Interviewees are encouraged to mention usage scenarios, such as using tail -f to locate interface errors.
File‑viewing commands: cat (full output, suitable for small files), less (paged view), head -n 20 (first 20 lines), tail -f (follow), and more. Example: tail -f logs/app.log during API testing.
Finding files: find /path -name "filename". Finding content: grep "keyword" filename. Combined example: find . -name "*.py" | xargs grep "def test_" to locate test functions across Python files.
File permission string rwxr-xr-- is broken down into owner (rwx), group (r-x), others (r--), with numeric representation 754. A real case: a script failed with "Permission denied" until chmod +x script.sh was applied.
Disk usage: df -h shows human‑readable filesystem stats, e.g., /dev/sda1 50G 30G 17G 64% /. Testers use it to verify sufficient space during performance runs.
Directory size: du -sh /path/to/directory (summary, human‑readable). Example: du -sh /var/logs to check log directory size.
Compression: tar -czvf archive.tar.gz /path/to/dir to compress, tar -xzvf archive.tar.gz to extract. zip -r archive.zip /path/to/dir and unzip archive.zip are also shown.
Hard vs. soft links: hard link ( ln file hard_link) shares the same inode, cannot cross filesystems; soft link ( ln -s file soft_link) stores a path and can cross filesystems. Testers often link configuration files to different environments.
2. Process Management and System Monitoring (7 questions)
List processes with ps aux, columns explained (USER, PID, %CPU, %MEM, COMMAND). Filter examples: ps aux | grep python, ps aux | grep nginx. Real case: confirming uwsgi is running during API testing.
Terminate processes: kill PID (graceful), kill -9 PID (force), pkill process_name, killall process_name. Example: forced kill of a hung test script.
System resource viewers: top (real‑time CPU/memory), with commands to sort ( P for CPU, M for memory) and quit ( q). htop is a more user‑friendly variant, not always pre‑installed.
Network connections: netstat -tulnp (tcp/udp listening ports with process IDs) and the modern replacement ss -tulnp. Example: checking if port 8080 is occupied.
HTTP testing with curl: GET request curl http://api.example.com/users, POST with JSON payload, adding headers, saving output, and using -v for verbose mode. Comparison with wget: wget focuses on file download (supports resume), while curl offers broader protocol support and is preferred for API testing.
Memory overview: free -h displays total, used, and available memory; the "available" column is more reliable than the plain free value.
3. Log Analysis and Text Processing (6 questions)
Real‑time log view: tail -f /var/log/app.log; pipe to grep ERROR to filter error lines.
Advanced grep usage: case‑insensitive -i, invert match -v, show line numbers -n, context -C 3, and regex with -E. Example: counting 500 errors with grep " 500 " app.log | wc -l.
Line/word/byte counts with wc -l, wc -w, wc -c. Combined with other commands, e.g., ps aux | wc -l to count processes.
Text extraction with awk: print first column awk '{print $1}' file.txt, print specific columns, or use field separator -F: for /etc/passwd. Real case: extracting response times from logs for analysis.
Batch replacement with sed: sed 's/old/new/g' file.txt (output only) and sed -i 's/old/new/g' file.txt (in‑place). Used to update IP addresses in configuration files.
Help lookup: command --help, man command, info command. Quick reference when a parameter is forgotten.
4. Network and System Management (5 questions)
Differences: ping tests ICMP reachability, telnet (or nc) tests port connectivity, nslookup / dig query DNS records. Typical workflow: ping → telnet → nslookup.
Environment variables: view with echo $PATH or env; set temporarily with export MY_VAR="value" or permanently by appending to ~/.bashrc.
Background execution: append & to a command, or use nohup command & to ignore hang‑up signals. Check background jobs with jobs or ps aux | grep command.
Scheduled tasks via crontab: format * * * * * command (minute hour day month weekday). Examples: daily backup at 02:00 and a check every 10 minutes.
System uptime and load: uptime shows how long the system has run and three load averages. Load close to the number of CPU cores indicates a busy system.
5. Practical Scenario Questions (4 questions)
Quick API verification: use
curl -X POST ... -d '{"username":"test","password":"123456"}', pipe JSON output to python -m json.tool, and monitor server logs with tail -f /var/log/app.log | grep "login".
Test environment failure troubleshooting steps: check process ( ps aux | grep uwsgi), port listening ( netstat -tulnp | grep 8080), error logs ( tail -n 100 /var/log/app.log | grep ERROR), resource exhaustion ( df -h, free -h, top), and finally restart the service ( systemctl restart uwsgi).
Batch management of multiple test machines: simple for host in server1 server2; do ssh $host "uptime"; done or use ansible for parallel command execution and deployment.
Handling a tricky Linux issue: a hanging automation script was traced with ps aux | grep python and strace -p PID, revealing a blocking read() on an HTTP request without a timeout; adding a timeout resolved the problem.
Summary: Required Linux Proficiency for Testers
Testers should master basic operations ( ls, cd, cat, grep, find, tar, chmod), process management ( ps, kill, top), log analysis ( tail -f, grep), networking tools ( curl, ping, netstat), and system monitoring ( df, free, uptime). Advanced skills like awk, sed, and shell scripting are beneficial but not mandatory.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
