Operation and maintenance must be mastered Linux interview questions

1, to explain what is under GPL, GNU, Free Software?

  • GPL :( General Public License): an authorization, any person has the right to acquire, modify, redistribute the power of free software.
  • GNU :( leather bondage plan): The goal is to create a completely free and open operating system.
  • Free Software: an unrestricted freedom to use, copy, software, study, modify and distribute. The main license GPL and BSD licenses have two kinds.

2, linux system, buffer cache, and how to distinguish?

  • buffer and cache is an area in memory, when the CPU needs to write data to disk, because the disk speed is relatively slow, so the CPU put data into the buffer, then the CPU to perform other tasks, the data buffer is written to on a regular basis disk;
  • When the CPU needs to read data from the disk, because the disk is slow, it can be used in the upcoming data in advance into cache, directly take data much faster than from the Cache CPU.

3, describes the meaning of each Linux run level 0-6

  • 0: Shutdown Mode
  • 1: single-user mode <== crack root password
  • 2: multi-user mode without network support
  • 3: multi-user mode network support (text mode, the most common work mode)
  • 4: Reserved, do not use
  • 5: X-windows network support multi-user mode (Desktop)
  • 6: reboot the system, i.e. reboot

4, a Linux system boot process from the boot to the login screen

  • ⑴ boot BIOS self-test, hard disk loading.
  • ⑵ read MBR, MBR boot.
  • ⑶grub boot menu (Boot Loader).
  • ⑷ load the kernel kernel.
  • ⑸ start the init process, set the operating level based inittab file
  • ⑹init process, the implementation rc.sysinit file.
  • ⑺ start the kernel module, perform different levels of script.
  • ⑻ execution /etc/rc.d/rc.local
  • ⑼ start mingetty, enter the system login screen.

5, Linux described in soft and hard links links distinction
in the Linux system, the link is divided into two, one is a hard link (Hard link), the other is called a symbolic link or a soft link (Symbolic Link).

  • ① default, with no arguments, ln creates a hard link, ln command with the -s parameter to create a soft link.
  • ② the same inode number of hard links and source files, and inode number of soft link to the file, the source file is different
  • ③ln command can not create hard links to directories, but you can create a soft link. Soft link to the directory will be frequently used.
  • ④ Delete soft link file, without any impact on the source files and hard linked files.
  • ⑤ deleted files hard-linked files, without any impact on the source file and the soft link file.
  • ⑥ delete the link to the file source file, no effect on the hard-linked files, it will lead to a soft link failure (red and white flashes like).
  • ⑦ delete the source files and the hard link file, the entire file will not actually be deleted.
  • ⑧ many hardware snapshot functionality, using a hard link is similar principle.
  • ⑨ soft links can span file systems, hard links can not cross file system.

6, shell script "$?" What is the use of the mark?
When writing a shell script, if you want to check whether the previous command is successful, if the conditions in the "$?" You can check the previous command end state. Simple examples are:

root@localhost:~# ls /usr/bin/
root@localhost:~# echo $?
0

If the end state is 0, indicating that the previous command executed successfully.

root@localhost:~# ls /usr/bin/share
ls: cannot access /usr/bin/share: No such file or directory
root@localhost:~# echo $?
2

If the end state is not 0, description of the command execution failed.

7, how to make history command specific time?

$ HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"
$ export HISTTIMEFORMAT

After the reboot will restore, you can write / etc / profile

8, with a shell statistics ip access cases, nginx access log analysis required to identify the number of page visits the former number 10 of the IP. The following is an excerpt nginx access log

202.101.129.218- - [26/Mar/2006:23:59:55 +0800] "GET /online/stat_inst.php?pid=d065HTTP/1.1" 302 20-"-" "-" "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1)"

Please write shell to achieve output top10 list of IP.

$ awk '{print $1}' access.log |sort|uniq -c |head -n 10
31 202.101.129.218
21 123.93.29.11
11 13.92.19.31

9, the local forwarding the request to the port 80 port 8080, local address 10.0.0.254, write command

$ iptables -t nat -A PRETOUTING -d 10.0.0.254 -p tcp --dprot 80 -j NDAT --to-destination 10.0.0.254:8080

10, Load high possibility of What?
Troubleshooting ideas:

  • 1. What process cpu occupancy rate of the first investigation. The command ps ux
  • 2. If the first step through the process of seeing a JAVA occupy high resources, see the corresponding java process CPU usage for each thread. Command: ps -Lp 15047
  • 3. tracking internal thread, see load is too high causes. Command: jstack 15047
    Other experience:
    the CPU of the Load surge, on the one hand and possible increase in the number of full gc related, on the one hand and possible death cycle related

11, description / etc / fstab file meaning of each field in?

  • (1) the first column: the file system name to be loaded;
  • (2) the second column: the mount point of the file system;
  • (3) The third column: the file system type;
  • (4) The fourth column: setting parameters;
  • (5) the fifth column: the last backup for the backup program to determine the number of days from now;
  • Sixth column (6): at system boot sequence detection system file.

12, how to exclude specific directories in the package?

$ tar --exclude=/home/dmtsai --exclude=*.tar -zcvf myfile.tar.gz /home/* /etc

13. how to generate a random password?

mkpasswd -l 8  -C 2 -c 2 -d 4 -s 0

14, how the statistics tcp status?

netstat -an | grep '^tcp' | awk '{++s[$NF]} END{for(i in s) print i "\t"s[i]}'

15, mysql root password forgotten how to do

$ mysqld_safe --user=mysql --skip-grant-tables --skip-networking & use mysql;

mysql> update user set password=password('123123') where user='root';
Published 180 original articles · won praise 13 · views 7179

Guess you like

Origin blog.csdn.net/weixin_45794138/article/details/104852630