Master Linux Interview Questions: 20 Essential Commands & Answers
This article presents 20 common Linux interview questions covering runlevels, default gateways, initramfs creation, cpio, patch, aspell, SPF lookup, package identification, bond0 status, /proc filesystem, file searches, strings, tee, environment variables, awk, at, and lspci, each with concise command‑line solutions.
Linux Interview Questions and Answers
1. How to view the current Linux server runlevel?
Use who -r or runlevel commands.
2. How to view Linux default gateway?
Run route -n or netstat -nr to display the routing table including the default gateway.
3. How to rebuild the initramfs image on Linux?
On CentOS/RHEL 5.x use:
# mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)On CentOS/RHEL 6.x use dracut : # dracut -f For a specific kernel version:
# dracut -f initramfs-2.x.xx-xx.el6.x86_64.img 2.x.xx-xx.el6.x86_644. What is the cpio command?
cpio copies files to and from an archive, allowing creation, listing, and extraction of files.
5. What is the patch command and how to use it?
patch applies a diff file to update source files. Example: # diff -Naur old_file new_file > diff_file Then apply:
# patch < diff_file6. What is aspell used for?
aspell is an interactive spell‑checking tool for Linux, often used by other programs or directly from the command line.
7. How to view a domain's SPF record from the command line?
Use dig -t TXT example.com .
8. How to identify the package providing a specific file (/etc/fstab)?
# rpm -qf /etc/fstab9. Which command shows the status of bond0?
# cat /proc/net/bonding/bond010. What is the purpose of the /proc filesystem?
/proc is a memory‑based virtual filesystem exposing kernel and process information such as CPU, memory, I/O, and running processes.
11. How to find files larger than 10 MB under /usr?
# find /usr -size +10M12. How to find files in /home modified more than 120 days ago?
# find /home -mtime +12013. How to find files in /var not accessed in the last 90 days?
# find /var \! -atime -9014. How to delete all "core" files in the entire directory tree?
# find / -name core -exec rm {} \;15. What does the strings command do?
strings extracts printable text strings from binary files, useful for forensic analysis.
16. What is the purpose of the tee filter?
tee duplicates standard input to both a file and standard output, allowing simultaneous viewing and saving of command output.
ll /etc | nl | tee /tmp/ll.out17. What does export PS1="$LOGNAME@hostname:$PWD:" do?
It changes the shell prompt to display the username, hostname, and current working directory.
18. What does ll | awk '{print $3,"owns",$9}' do?
It prints each file's owner and name from the long‑listing output.
19. What is the at command used for?
at schedules a one‑time command execution, storing jobs in /var/spool/at and executing them via the atd daemon.
20. What does the lspci command do?
lspci lists PCI devices; adding -v , -vv , or -vvv provides increasingly detailed output, and -r improves readability.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
