Essential Linux Command Cheat Sheet: 20 Must‑Know Answers for Sysadmins
This article provides concise answers to 20 common Linux command‑line questions, covering how to check runlevels, default gateways, initramfs creation, use of cpio, patch, aspell, SPF lookup, package ownership, bond status, /proc filesystem, and file‑search utilities for size, age, and access.
Q1: How to view the current Linux server runlevel? Use who -r or runlevel commands.
Q2: How to view Linux's default gateway? Run route -n or netstat -nr to display the default gateway and the routing table.
Q3: 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 -f for the current kernel or
dracut -f initramfs-2.x.xx-xx.el6.x86_64.img 2.x.xx-xx.el6.x86_64for a specific kernel version.
Q4: What does the cpio command do? It copies files into or out of an archive, allowing you to create or extract archive files.
Q5: What is the patch command and how to use it? patch applies changes (diffs) to files. Create a diff with diff -Naur old_file new_file > diff_file, then apply it using patch < diff_file.
Q6: What is aspell used for? It is an interactive spell‑checker for Linux, a free alternative to ispell, usable both as a standalone tool and as a library for other programs.
Q7: How to view a domain's SPF record from the command line? Use dig -t TXT example.com (replace with the target domain).
Q8: How to identify the package that provides a specific file (e.g., /etc/fstab )? Run rpm -qf /etc/fstab.
Q9: Which command shows the status of bond0 ? Use cat /proc/net/bonding/bond0.
Q10: What is the purpose of the /proc filesystem? It is a memory‑based virtual filesystem exposing kernel and process information such as CPU, memory, partitions, I/O addresses, DMA channels, and running processes.
Q11: How to find files larger than 10 MB under /usr ? Execute find /usr -size +10M.
Q12: How to locate files in /home not modified in the last 120 days? Use find /home -mtime +120.
Q13: How to find files in /var not accessed in the past 90 days? Run find /var ! -atime -90.
Q14: How to delete all files named core in the entire directory tree without prompts? Use find / -name core -exec rm {} ;.
Q15: What does the strings command do? It extracts printable strings from binary files, useful for analyzing unknown binaries or investigating potential intrusions.
Q16: What is the purpose of the tee filter? It duplicates standard input to both a file and standard output (or another program). Example: ll /etc | nl | tee /tmp/ll.out.
Q17: What does export PS1="$LOGNAME@hostname:$PWD:" change? It modifies the shell prompt to display the username, hostname, and current working directory.
Q18: What does ll | awk '{print $3,"owns",$9}' do? It prints each file's owner (field 3) followed by the word "owns" and the file name (field 9).
Q19: What is the at command used for? It schedules a one‑time task to run at a specified future time, stored under /var/spool/at and executed by the atd daemon.
Q20: What does the lspci command display? It lists PCI bus devices and attached hardware; options -v, -vv, or -vvv increase verbosity, 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.
