20 Linux Command Interview Questions and answers

Source: Internet
Author: User

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.

Q: 2. How do I 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?

A: In CentOS 5.X/RHEL 5.X, you can use the mkinitrd command to create an initial memory disk file. For example:

  1. # 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/RHEL 6. X, use the dracut command to create an initial memory disk file. For example:

  1. # 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:

  1. # 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,

  1. # 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:

  1. # 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?

A: You can use the dig command to view the SPF records of the domain. Example:

  1. Linuxtechi @ localhost :~ $ Dig-t TXT google.com

Q: 8. How to identify the associated packages of a specified file (/etc/fstab) in Linux?

A:

  1. # 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:

  1. 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:

  1. # Find/usr-size + 10 M

Q: 12. How can I find the file that was modified 120 days ago in the/home directory?

A:

  1. # Find/home-mtime plus 120

Q: 13. How can I find files that have not been accessed within 90 days under the/var directory?

A:

  1. # 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:

  1. # 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. (LCTT Note: 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 ).

  1. 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 by the atd 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.

This article permanently updates the link address:

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.