Linux operation and maintenance interview questions

1. Delete the file whose file name is...log 30 days ago

find log/ -mtime +30 -a -type f -a -name "*.log" -exec rm -f {} \;
   find log/ -mtime +30 -a -type f -a -name "*.log" | xargs rm -f
   Rm -rf $( -mtime +30 -a -type f -a -name "*.log")

2. NIC configuration path

  /etc/sysconfig/networkmask-scripts/ifcfg-ens32

3. Router add and delete routing entries
Static routing

route add -net 192.168.28.0/24 gw 192.168.13.1
  route del -net 192.168.28.0/24 gw 192.168.13.1

Default route

  route add default gw 192.168.13.1
  route del default gw 192.168.13.1

4.cat /etc/fstb/
What is in this file?
How to write the
mount file, mount directory, type, mount option (default), whether to backup, whether to verify the boot.
5. What type of failure is encountered, and how to deal with it.
Delete the system and hang in the directory and cannot enter.
Enter the root password, repair
vi /etc/fstab and comment out, reboot
mount -o remount, rw /: remount the root with read and write, and then It can be modified
6. The current root file system is 20G, and the LV made based on LVM is named "/dev/mapper/centos-root". With the
daily system use, the remaining space is obviously insufficient, and the root file system needs to be expanded. A new hard disk /dev/sdd (20G) is added.
If I want to extend this hard disk to the root file system, what should I do?

1. Create PV (dev/sdd)
2. Expand the original volume group cenos
3. Expand the original logical volume /dev/cetos/root
4. Refresh the logical volume
Specific operation:
Shut down and add hard disk (20G)

  ls /dev/sdd
  df -hT
  pvscan
  vgdisplay cenos  (free PE /size 0)
  pvcreate /dev/sdd
  vgextend centos /dev/sdd
  vgdisplay centos
  lvextend -l +5119 /dev/centos/root
  xfs_growfs /dev/centos/root
  df -hT

7. Commonly used RAID levels, features
0-6, combination models 1 0.

8. The kernel version
3.10 of the server has been used before
9. Why can some commands (tar ps) not add "-"? What are the contents of
inherited unix
10.top commands?

Insert picture description here

Current time, online time, users, average load (1min, 5min, 15min average load, single and dual core)
total number of tasks, running number, sleep number, stopped,
total number of zombie process cpu cores (press 1 to display all cores), user, system, nice, idle, IO-wait, hi (hard interrupt), si (soft interrupt), st (virtualized disk saving)
kb unit memory, idle, used, cache
kb unit swap partition, idle, already Use, free space.

11. What kernel file
Vmlinuz-2.6.32-432.e16.*86_64 used for your company’s server before

12.centos 6 boot default run level configuration
Insert picture description here
Insert picture description here

Cat /etc/redhat-release
CentOS release 6.5 (Finanl)     #是6.5版本
Vim /etc/inittab
  

/etc/systemctl

Insert picture description here

Modify the character graphic interface to switch boot

Insert picture description here

13. System-level security reinforcement
Insert picture description here

14. What is the reason why there is still a block but the content cannot be written in?
The i-node is exhausted, and the reason for the disk quota is
15. Add and delete routing entries.
(1) Temporary:
1) Static
add: route add -net network segment/short format mask gw gateway
Subtract: route del -net network segment/short format mask gw gateway
2) Default
add: route add default gw gateway
subtract: route del default gw gateway
(2) permanent
1) CentOS6: vi /etc/rc.local (automatically boot file after booting)
CentOS7: vi /etc/rc.local or vim /etc/rc.d/rc.local
2) The default route can be added to /etc/sysconfig/network-scripts/ifcfg-ens32
3)Vi /etc/sysconfig/static-routers (static)
Example: any net 192.168.200.0/24 gw 192.168.250.254
16. DNS resolution query method
1). Recursive query 2). Iterative query
17. ssh service absolute path
/etc/ssh/sshd

18. You have faced the company’s most difficult problem.
There are customer feedback on the problem of not being able to access the website. The
website has a 5XX error solution. The
website suddenly becomes very slow. The solution is that the
cpu is high. The case. The
database is forcibly closed. Cases When
performing activities, CDN bandwidth suddenly increased a lot of troubleshooting cases
IDC computer room traffic skyrocketing solution case analysis of the
company’s old website migration failure case analysis of
one master, multiple slaves, main server downtime solution case
database server CPU periodically high solution case
The website was attacked by a Trojan horse, causing all the files in the website directory to be tampered with. The
fstab modification error caused the system to fail to start. Repair case After the
Linux server was invaded, how to catch the
Trojan horse in the Linux server, how to clean and scan the
server after the mining Trojan horse was implanted ,
The solution to the
high cpu , the solution to the downtime of 9 nosql databases, the solution to the cpu exhaustion
caused by the large concurrent slow query The solution to the downtime caused by the scheduled task The case of the
inode full and the disk cannot be written to the
remote connection speed of the cloud server Slow case
Solving case of server disk damaged due to power outage
mysql innodb abnormal repair case
Analysis case of deleted data but disk space problem analysis case
Linux Argumet list too long error solution case zabbix
-server intrusion solution case
The attack caused by the zabbix vulnerability caused the memory to be full, and the server was down. The
redis vulnerability reinforcement solution. The
server mining virus investigation case

19. The written test is easy to take, and the variables are predefined
Insert picture description here

20. Four watches and five chains
Insert picture description here
Insert picture description here
Insert picture description here

21. The difference between char and vacgar

Insert picture description here

22. Tomcat server failure
Failure 1:
Failure phenomenon: WEB can not be accessed, SSH can not log in, desktop login verification fails. You can log in normally after restarting the server.
Fault information: By checking the system log, it is found that cat /var/log/message shows that the root user has created more than 2000 sessions and shows that the memory is insufficient. Enter the tomcat installation directory (/usr/local/tomcat7/logs/) to view the log localhosts_time.log (log of the day). Found the following error: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
failure determination: created by tomcat Too many sessions, resulting in insufficient system memory. The above problem occurs.
Solution:
Increase the memory of the JVM virtual machine in the catalina.sh file JAVA_OPTS="-server -Xms4096m -Xmx4096m -XX:PermSize=128M
-XX:MaxPermSize=256m -XX:NewSize=256m -XX:MaxNewSize=512m" (The adjustment variable names for non-heap memory in tomcat7 and tomcat8 are different)

Failure 2
Failure phenomenon: Tomcat access report 500 error, unable to provide external services. Multiple Tomcat services are abnormal.
Troubleshooting: Check system resources. Memory has increased slightly, CPU, bandwidth, and other loads have decreased significantly. There is no obvious change in the number of TCP connections in the ESTABLISHED state, but the number of non-ESTABLISHED states has greatly decreased. Restart the service Dafa at the first time. After restarting, the service can be provided for a short time, but it immediately returns to the stuck state. Use jstack to see that there are many processes stuck in network access. At the same time, an application log reported that a certain service address failed to access. I remembered that in order to optimize the error that the domain name could not be resolved with a small probability, I wrote the domain name IP into the hosts file.
Fault determination: Due to the change of the IP address corresponding to the domain name of a third-party server, the IP address written in the hosts is wrong, and the response timeout time is too long, resulting in a large number of Tomcat threads and unable to accept new requests. This further causes other Tomcats to fail to respond due to the Tomcat's problem and the same thread is full, unable to respond to new requests, resulting in a server avalanche problem. Therefore, restarting multiple times is invalid, and after modifying it to the correct IP address, it returns to normal.
Solution:
1. Increase the timing of the script's high frequency (1 time per minute or slower) to determine whether the IP has changed and refresh the hosts file;
2. Modify tomcat to have a larger number of threads;
3. Shorten the request to third parties The timeout period is about 10 seconds according to the specific situation;
4. If this part of the request does not affect the business, use the message queue asynchronous processing to reduce the thread occupation;
5. Increase the fuse mechanism to avoid avalanches when abnormal

23. The difference between soft and hard links The difference between
hard link and soft link
1. Delete the source file, hard link has no effect, soft link is unavailable
2. Soft link can cross file system, hard link can not
3. Hard link inode number is the same, soft Connecting to different
directories cannot be used as hard links, but can be used as soft links

24. The difference between CentOS 6 and 7

Insert picture description here

25. What else is the process state besides S and R?
R: (task_running) executable state
S: (task_interruptible) interruptible sleep state
D: (task_ununinterruptable) uninterruptible sleep state
T: (task_stopped or task_traced) suspended state or tracking state
Z: (task_dead-exit_zombie) exit state, The process becomes a zombie process
X: (task_dead-exit_dead) exit status, the process is about to be destroyed

26. What is a process? What is thread, concurrency and parallelism?
Process: the basic unit of resource allocation with independent space.
Thread: the basic unit of independent CPU operation and independent scheduling.
Concurrency: multiple simultaneous events can be processed.
Parallel: simultaneous processing Multiple things

27. What are the common RAID levels?
RAID 0 striping mode improves read and write speed, and data is not redundant.
RAID 1 mirror mode has high data security and low disk usage. Only even-numbered disks can be used.
RAID 5 distributed parity allows one hard disk to be damaged and write speed slows. , Use at least three hard drives

28. If you execute rm -rf* by mistake one day, what will happen
to the unauthorised files in the computer will be deleted, the system commands will be deleted and cannot be used, grub.conf will be deleted, the system will not be able to boot, and the whole system will be difficult to normal Running

29. What are the common Linux system release versions?
RedHat, Centos, suse, ubuntu, fedora

30. The principle
of FTP active and passive mode The connection process of PORT (active) mode is: the client sends a connection request to the server's FTP port (the default is 21), the server accepts the connection, and establishes a command link. When data needs to be transmitted, the client uses the PORT command on the command link to tell the server: "I opened the XXXX port, you come to connect to me". So the server sends a connection request from port 20 to port XXXX of the client, and establishes a data link to transmit data.

The connection process in PASV (passive) mode is: the client sends a connection request to the server's FTP port (the default is 21), the server accepts the connection, and establishes a command link. When data needs to be transmitted, the server uses the PASV command on the command link to tell the client: "I opened the XXXX port, you come to connect to me". Then the client sends a connection request to the XXXX port of the server to establish a data link to transmit data.

Comparison between ansible and SaltStack:

Similarities:
1. Both are developed using python language
2. Both have the characteristics of secondary development
3. The execution commands all support Ad-hoc mode (temporary commands, return after execution)
4. All can be executed in batches through YAML format files
5. The returned results are all JSON data, which is convenient for subsequent processing

Differences:
1. Ansible deployment is simpler, there is no client, while Saltstack has a client;
2. Saltstack's response speed is faster than Ansible; Ansible is implemented through the SSH protocol, and Saltstack uses ZeroMQ to achieve communication;
3. Ansible is more secure , SSH encrypted transmission
4. Saltstack is more friendly to Windows support, Ansible manages Windows through Power Shell
5. Ansible is simple to maintain, no client, no daemon; saltstack needs Master and minion, and the host needs to start a daemon.

32.pxe installation process

DHCP get ip, get tftp server address
Tftp server>>>initrd.img pxelinux.0 pxelinux.cfg/defultS>>>ftp address ks.cfg file address
ftp provides the mirror image, get the mirror file, and then follow the content of ks.cfg To install

1) Prepare the Centos6 installation source and place it under /var/ftp/centos6
2) Install the tftp service, enable, modify the tftp configuration
3) Prepare the linux kernel, initialize the mirror
4) Prepare the pxe boot program, start the menu file
5) Install and enable dhcp Service
6) Create a new virtual machine, set up network boot and verify
7) Realize kikstart unattended installation
8) Use Pxe and kikstart together to realize batch installation

33.Redis data type
The value in redis can be composed of string, hash, list, set, zset, geo and other data structures and algorithms.

34. Is Redis single-threaded or multi-threaded, and why is it so? Why does Redis6 increase multithreading?
1. When Redis processes the client's request, including acquisition (socket reading), parsing, execution, content return (socket writing), etc., all are
processed by a sequential main thread, which is the so-called "single thread". But strictly speaking, it is not single-threaded since Redis 4.0. In addition to the main thread, there are also background threads that are processing some slower operations, such as cleaning up dirty data, releasing useless connections, deleting large keys, and so on.
2. Official response: When using Redis, there is almost no situation where CPU becomes a bottleneck. Redis is mainly limited by memory and network. For example, on an ordinary Linux system, Redis can handle 1 million requests per second by using pipelining, so if the application mainly uses O(N) or O(log(N)) commands, it will hardly take up too much CPU.
After using single thread, maintainability is high. Although the multi-threaded model performs well in some aspects, it introduces the uncertainty of program execution order, brings a series of problems of concurrent reading and writing, increases the complexity of the system, and may have thread switching or even locking. Performance loss caused by unlocking and deadlock. Redis through the AE event model and IO multiplexing and other technologies, the processing performance is very high, so there is no need to use multi-threading. The single-threaded mechanism greatly reduces the complexity of Redis's internal implementation. Hash's lazy Rehash, Lpush, and other "thread-unsafe" commands can be performed without locks.
3
• Can make full use of server CPU resources, currently the main thread can only use one core
• Multi-threaded tasks can share the Redis synchronous IO read and write load

Guess you like

Origin blog.csdn.net/qq_39109226/article/details/111193901