20 Linux Command Interview Questions and Answers, 20 linux commands
Source: bole online
Q: 1. How can I view the running level of the current Linux server?
A:who -rAndrunlevelCommand can be used to view the currentLinuxThe running level of the server.
Running level:
- 0-stopped
initdefaultSet to 0)
- 1-Single User Mode
- 2-multiple users, but no
NFS
- 3-full multi-user mode
- 4-useless
- 5-
X11
- 6-Restart (do not set
initdefaultSet to 6)
Q: 2. How do I view the default gateway of Linux?
Answer: Yesroute -nAndnetstat -nrCommand to view the default gateway. In addition to the default gateway information, these two commands can also display the current route table.
Q: 3. How can I re-initialize the memory disk image file on Linux?
linuxMemory Initialization Technology (initrdIs used to support the two-phase system boot process. It is a temporaryrootFile System.initrdContains many executable programs and drivers, and allows the root file system of the temporary memory disk to be detached. After the memory is released, the actualrootFile System. In many Embedded SystemslinuxIn the file system,initrdIs the final root file system.
What is memory disk initialization?
initrdThe Mount priority is higher than the real root file system. It is bound to the kernel and loaded as part of the kernel Startup Process (load). Then, as the first part of the two-phase boot process (mount)initrdTo obtain and load a truly valid file system. To achieve this goal,initrdContains at least directories and programs, suchinsmodTo install the kernel module to the kernel.
For desktops or serverslinux,initrdIt is a temporary file system and has a short life cycle. It serves only as a bridge to reach the real root file system. But for an embedded system without storage devices, it is a permanent root file system.
More information
A: InCentOS 5.X / RHEL 5.X, You can usemkinitrdCommand to create the initialization memory disk file, for example:
# mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)
If you want to create an initial memory disk for a specific kernel version, replace it with the required kernel name.uname -r.
InCentOS 6.X / RHEL6.X, UsedracutCommand to create the initialization memory disk file, for example:
# dracut -f
The above command can create an initial memory disk for the current system version, and re-initialize the memory disk file for a specific kernel version using the following command:
# dracut -f initramfs-2.x.xx-xx.el6.x86_64.img 2.x.xx-xx.el6.x86_64
Q: What is the 4 cpio command?
A:cpioThat is, the meaning of copy-in and copy-out.cpioYou can copy and list an archive file (or a single file) and Extract files from it.
Q: What is the 5 patch command? How to use it?
A: As the name implies,patchA command is used to write modifications (or patches) into a text file.patchCommands generally receivediffAnd convert the old version of the file to the new version. For example,LinuxThe kernel source code consists of millions of lines of code files. Therefore, whenever any code contributor contributes code, it only needs to send the modified part instead of the entire source code, and then the receiver usespatchCommand to write the changes into the original source code.
Create a diff file for the patch,
# diff -Naur old_file new_file > diff_file
Old and new files are either single files or directories containing files,-rThe parameter supports directory tree recursion.
OncediffAfter the file is created, we can patch the old file and change it into a new file:
# patch < diff_file
Q: What is the use of 6 aspell?
A: As the name implies,aspellYesLinuxAn interactive spelling checker on the operating system.aspellThe command succeeded an earlier one namedispellAnd as a free alternative, the most important thing is that it is very useful. WhenaspellWhen a program is used by other programs that require spelling check, it can also be used as an independent tool in the command line.
Q: 7. How can I view the domain SPF records from the command line?
SPFIt is proposed to prevent spam.DNSRecord type, which is a typeTXTType of record, which is used to register all the records owned by a domain name for external mail.IPAddress. FollowSPFInDNSAdd a recordTXTThis type of record increases the credibility of the domain name, and prevents spam from spoofing the sender of the domain to send spam.SPFYesfollowDNSThe content of a related technology is written inDNSOftxtType record.mxThe purpose of the record is to indicate to the sender what is the email server of a domain name.SPFAndmxInstead, it indicates to the recipient which email servers will send emails after a domain name is approved.
As can be seen from the definition,SPFAnti-Spam is the main function of anti-spam, mainly for spam mail that the sender spoofs the domain name.
A: We can usedigCommand to view the domainSPFRecord. Example:
linuxtechi@localhost:~$ dig -t TXT google.com
Q: 8. How to identify the associated packages of a specified file (/etc/fstab) in Linux?
A:
# rpm -qf /etc/fstab
The above commands can list and provide/etc/fstabThe package of this file.
Q: 9 which command is used to view the status of bond0?
A:
$ cat /proc/net/bonding/bond0
Q: 10 what is the use of the/proc file system in Linux?
A:/procA file system is a memory-based file system that maintains information about the currently running kernel status, includingCPU, Memory, partition,I/OAddress, Direct Memory Access Channel, and running process. This file system does not represent various files that actually store information. They point to information in the memory./procThe file system is automatically maintained by the system.
Q: 11. How can I find files larger than 10 MB in the/usr directory?
A:
# find /usr -size +10M
Q: 12. How can I find the file that was modified 120 days ago in the/home directory?
A:
# find /home -mtime +120
Q: 13. How can I find files that have not been accessed within 90 days under the/var directory?
A:
# find /var \! -atime -90
Q: 14. Search for the file "core" under the entire directory tree. If you find the file, you do not need to delete it directly.
A:
# find / -name core -exec rm {} \;
Q: What is the role of the 15 strings command?
A:stringsCommand to extract and display text strings in non-text files. When used to analyze the inexplicable binary program on your system, you can find suspicious file access, which is useful for tracking intrusion)
Q: What is the role of the 16 tee filter?
A:teeThe filter is used to send output content to multiple targets. If it is used for pipelines, it can copy the output to one file and copy the other to the screen (or some other programs ).
$linuxtechi@localhost:~$ ll /etc | nl | tee /tmp/ll.out
In the preceding examplellOutput can be captured/tmp/ll.outFile and displayed on the screen.
Q: 17 export PS1 = "$ LOGNAME @ hostname: \ $ PWD: What is this command?
A: This oneexportCommand will change the logon prompt to display the user name, local name, and current working directory.
Q: 18 ll | awk '{print 3, "owns ", 9} 'What is this command?
A: This onellThe command displays the file names and owners of these files.
Q: 19: what is the use of the at command in Linux?
A:atThe command is used to schedule a one-time execution of a program in the future. All submitted tasks are placed in/var/spool/atDirectory and the execution time is reachedartdDaemon.
Q: What is the role of the lspci command in linux?
A:lspciCommand to display your systemPCIBus and additional device information. Specify-v,-vvOr-vvvTo get more and more detailed output, plus-rThe output of the command is more portable.