20 Linux Command Interview Questions and answers

Source: Internet
Author: User
Tags mx record

20 Linux Command Interview Questions and answers


Q: 1. How can I view the running level of the current Linux server? A: the who-r and runlevel commands can be used to view the running level of the current Linux server.

Running level:
0-downtime (do not set initdefault to 0) 1-Single User Mode 2-multiple users, but there is no NFS3-full multi-user mode 4-5-X116-Restart not used (do not set initdefault to 6) Q: 2 how to view the default gateway of Linux?

A: run the route-n and netstat-nr commands 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?

Linux memory initialization Technology (initrd) is used to support two-phase system boot process. It is a temporary root file system mounted during system startup. Initrd contains 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 real root file system is mounted. Initrd is the final root file system in many embedded linux file systems.

What is memory disk initialization?

Initrd has a higher Mount priority than the real root file system. It is bound to the kernel and is loaded as part of the kernel startup process ). Then, as the first part of the two-phase boot process, the kernel mount (mount) initrd is used to obtain and load a truly valid file system. For this purpose, initrd contains the minimum directory and programs, such as insmod, to install the kernel module into the kernel.

For desktop or Server linux, initrd is a temporary file system with 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: In CentOS 5.X/RHEL 5.X, you can use the mkinitrd command to create an initial 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 uname-r with the required kernel name.

In CentOS 6.X/RHEL6.X, use the dracut command to create an initial 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: cpio means copying data. Cpio can copy files and lists to 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, the patch command is used to write modifications (or patches) into text files. The patch command usually receives diff output and converts the old version of the file to the new version. For example, the Linux kernel source code is composed of millions of lines of code files. Therefore, at any time, any code contributor contributes the code by sending the modified part instead of the entire source code, the receiver then writes the changes to the original source code using the patch command.

Create a diff file for the patch,

# diff -Naur old_file new_file > diff_file

The old and new files are either single files or directories containing files. The-r parameter supports directory tree recursion.

Once the diff 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 its name implies, aspell is an interactive spelling checker on the Linux operating system. The aspell command succeeded an earlier program named ispell, and as a free alternative, the most important thing is that it is very useful. When the aspell program is mainly used by other programs that require spelling check capability, it can also be very effective as a standalone tool in the command line.

Q: 7. How can I view the domain SPF records from the command line?

SPF is a DNS record type proposed to prevent spam. It is a TXT record used to register all IP addresses owned by a domain name for external mail. Adding a TXT record to the DNS record in SPF format will increase the credibility of the domain name and prevent spam from spoofing the sender of the domain. SPF is a DNS-related technology. Its content is written in the txt record of DNS. The mx record is used to indicate to the sender the mail server of a domain name. SPF is opposite to mx. It indicates to the recipient which email servers will send emails after a domain name is approved.

From the definition, we can see that SPF is mainly used for anti-spam, mainly for spam emails with spoofed domain names of senders.

A: You can use the dig command to view the SPF records of the domain. 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 preceding command lists the packages that provide the/etc/fstab 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: The/proc file system is a memory-based file system that maintains information about the running kernel status, these include CPU, memory, partition, I/O address, Direct Memory Access Channel, and running processes. This file system does not represent various files that actually store information. They point to information in the memory. The/proc 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: The strings command is used to extract and display text strings from 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: The tee 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 example, the/tmp/ll. out file can be captured from the ll output and displayed on the screen.

Q: 17 export PS1 = "$ LOGNAME @ hostname: \ $ PWD: What is this command?

A: This export command changes 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: The ll command displays the file names and owners of these files.

Q: 19: what is the use of the at command in Linux?

A: The at command is used to schedule a one-time execution of a program in the future. All submitted tasks are stored in the/var/spool/at directory and executed through the artd daemon at the execution time.

Q: What is the role of the lspci command in linux?

A: The lspci command is used to display information about the PCI bus and additional devices on your system. Specify-v,-vv, or-vvv to obtain more and more detailed output. If the-r parameter is added, the output of the command is more readable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.