Interview questions for Linux O & M engineers

Source: Internet
Author: User
Tags ftp client apache access log apache log ftp protocol mx record record mx
Linux O & M engineer interview question 1. file file11 is available. use shell to query the row number awk & amp; lsquo; {if ($0 ~ /^ $/) PrintNR} & amp; rsquo; fileorgrep-n ^ $ file | awk & amp; lsquo; BEGIN {FS :}{ print $1} & amp; linux O & M engineer interview question 1. file file11 is available. use shell to query the row number awk of the empty line in file1 {if ($0 ~ /^ $/) Print NR} 'fileorgrep-n ^ $ file | awk' BEGIN {FS = ": '} {print $1}' 2. compile ShellScript to query the row grep abc $ file1 ending with abc in file1 3. print the 1st to 3rd rows of file1 sed-n' 1, 3 p 'file1head-3 file1 2. how to forward requests from local port 80 to port 8080, the current host IP address is 192.168.2.1Iptables-a prerouting-d 192.168.2.1-p tcp-m tcp-dport 80-j DNAT-to-destination 192.168.2.1: 8080. 3. crontab is available in March, run/usr/bin/httpd every two hours from to every day. how to implement sh 0 6-12/2*11 */us R/bin/httpd. sh 4. write a shell script to transfer the files larger than 100 K under the/usr/local/test directory to the/tmp Directory #! /Bin/bashfor file in 'ls/root' doif [-f $ file]; thenif ['ls-l $ file | awk '{print $5} ''-gt 10000]; thenmv $ file/tmp/mongoidone 5. briefly describe the working principles and features of raid0 raid1 raid5. RAID 0: continuous data split by bit or byte and read/write in parallel on multiple disks. Therefore, RAID 0 has a high data transmission rate, but it has no data redundancy, therefore, it cannot be regarded as a real RAID structure. RAID 0 only improves performance and does not guarantee data reliability. However, failure of a disk affects all data. Therefore, RAID 0 cannot be used in scenarios with high data security requirements. RAID 1: it achieves data redundancy through disk data images, and generates mutually backed up data on paired independent disks. When raw data is busy, data can be directly copied from the image, so RAID 1 can improve read performance. RAID 1 is the most costly disk array, but provides high data security and availability. When a disk fails, the system can automatically switch to the image disk to read and write data without restructuring the invalid data. Simply put, the image structure is similar to the backup mode. one data is copied to two hard disks. RAID10: a high-reliability and high-efficiency disk structure with a zone structure and a mirror structure, because the two structures have their own advantages and disadvantages, so they can complement each other. It is mainly used in databases with small capacity but requires speed and error control. RAID5: the structure of an independent distributed parity disk. its parity code exists on all disks. if any hard disk is damaged, damaged data can be reconstructed based on the parity bits on other hard disks. A disk can still run normally after it is disconnected. VI. physical backup for oracle Database Backup: enable network listening and back up database files. RMAN backup: backs up ORACLE data in RMAN mode using tablespace files. 7. how to view the lsof-I: 8080 processes occupying Port 8080 8. write the two working modes of apache2.X and their working principles. How can I view the modules currently supported by apache and view the working mode? Answer: prefork (multi-process, each process generates sub-process) and worker (multi-process, each process generates multiple threads) the working principle of prefork is, after the "StartServers" sub-process is initially created, the control process creates a process to meet the needs of the MinSpareServers settings. wait for one second to create two more processes. wait for another second to create four more processes ...... In this way, the number of created processes is increased exponentially, up to 32 processes per second until the value set by MinSpareServers is met. This is the origin of prefork. This mode eliminates the need to generate new processes when requests arrive, thus reducing system overhead and increasing performance. Worker is a brand new MPM that supports multi-thread and multi-process hybrid models in version 2.0. Because threads are used for processing, a relatively large number of requests can be processed, and the overhead of system resources is smaller than that of process-based servers. However, worker also uses multiple processes, and each process generates multiple threads to achieve stability based on the process server. This kind of MPM will be the trend of Apache 2.0. You can run the httpd-l command to view the current module of apache. if worker. c is included, it works in worker mode. if prefork. c is included, it works in prefork. c mode. 9. have you used monitoring software? Nagios is used to monitor servers. its features enable real-time alerts for SMS, email, MSN, and Apsara. Use cacti to monitor traffic. 10. your understanding of current O & M engineers and understanding of their work O & M engineers are of great responsibility in the company, we need to ensure the highest, fastest, most stable, and most secure services for the company and its customers at all times. A small mistake made by O & M engineers may cause significant losses to the company and customers. Therefore, O & M engineers must be rigorous and innovative. 11. What are common DNS software in linux? I will cite several common DNS records. if the domain name abc.com is configured with an email server, the IP address will be 202.106.0.20, how can I resolve the issue? Whether you understand the smart resolution of bind. if you know about it, briefly explain the principle. answer: 1) the commonly used DNS software is bind2) A record address record MX record email exchange record CNAME record alias domain record 3) modify the configuration file of the abc.com domain name and add the following record in mx 10 mail.abc.com. mail in a 202.106.0.204) bind resolves the IP address of the client based on the request. The principle is to set the view IN the configuration file, each view has an IP address segment of the client. the bind server parses the IP address of the client based on the request and matches different views. then, based on the configuration of the view, query the corresponding configuration file and return the result to the requesting client. 12. use apache access log access. log to count the number of accesses by IP address and each address, and list the top 10 by traffic. Log Format example: 192.168.1.247--[02/Jul/2010: 23: 44: 59 + 0800] "GET/HTTP/1.1" 200 19 answer: cat access_log | awk '{print $1}' | uniq-c | sort-rn | head-10 // This method can also be used for statistics, but some commands are necessary for awk, sort and uniq mainly depend on whether these commands are used. 13. how can I use the mysql command for backup and recovery? Take the test database as an example to create a backup and use the backup for restoration. Mysqldump-u root-p test> test. sqlmysql-u root-p test <test. SQL // Check the peer msqldump> test. SQL and mysql <test. SQL 14. what do you think are involved in system tuning? take linux as an example to briefly describe and take some parameters as an example. Answer: system optimization includes two aspects: kernel parameter optimization and application optimization. the other party can elaborate on these two aspects as much as possible. There is a file as follows: http://a.domain.com/1.html http://b.domain.com/1.html http://c.domain.com/1.html http://a.domain.com/2.html http://b.domain.com/2.html http://a.domain.com/3.html Requirement: obtain the host name (and domain name), calculate the number of times that the website appears, and sort it. It can be shell or C. The result should be: 3 a. domain. com2 B. domain. com1 c.domain.com [root @ mail ~] # Awk 'In in {FS = "/"} {arr [$3] ++} END {for (I in arr) printarr [I], i} 'list | sort-r answer 3. domain. com2 B. domain. com1 c.domain.com mount the windows shared directory? Mount. cifs // IP/SHARE linux directory -- verbose-o user = username <-- This user is a user in windows -- verbose this parameter can be left blank, it is a display process such as mount. cifs // 10.1.1.246/gongxiang/mnt -- verbose-o user = gao or mount-t cifsumount/mnt or umount. cifs/mnt-l <-- cancel mounting graphic interface: smb: // ipa B network is accessible. the nfs, ftp, scp, rsync, samba, http: // 1. assume that the log file generated by Apache is named access_log. When apache is running, run the command mvaccess_log access_log.bak. after the command is executed, where will the new apache log be printed? why? The new log is printed in access_log.bak, because the access_log file is found at apache startup and you are ready to add log information to the file at any time. although the file is renamed, the service is running, because the position of its inode node has not changed, the fd opened by the program will still point to the original inode, and will not change because of the change in the file name. Apache will continue to append logs to renamed files. However, if the apache service is restarted, the system will check whether the access_log file exists. if the access_log file does not exist, it will be created. 2. in the Shell environment, how does one view how long the remote Linux system has been running? 2. run the command on the monitoring host: ssh user @ ip address of the monitored host "uptime" to obtain the uptime3. process the following file content on the monitored host, retrieve the domain name and sort it by count, for example: http://www.baidu.com/index.html http://www.baidu.com/1.html http://post.baidu.com/index.html http://mp3.baidu.com/index.html http://www.baidu.com/3.html http://post.baidu.com/2.html The following result is displayed: Domain name 3 www. baidu. com2 post. baidu. com1 mp3.baidu.com can be any of bash/perl/php/c. 3. [root @ localhost shell] # cat file | sed-e's/http: \/\ // '-e's /\/. * // '| sort | uniq-c | sort-rn3 www. baidu. com2 post. baidu. com1 mp3.baidu.com [root @ codfei4 shell] # awk-F/'{print $3}' file | sort-r | uniq-c | awk '{print $1 "\ t", $2} '3 www. baidu. com2 post. baidu. com1 mp3.baidu. com4. if a random string is obtained, the length can be defined in the values table of the string, and the string Display in reverse order. for example, if 0123456789 is used as the benchmark string limit table, a 6-digit string 642031 is generated, and the printed string is 130246. bash/perl/php/c can be used as any one. 4. [root @ localhost ~] # Awk-v count = 6 'In in {srand (); str = "0123456789"; len = length (str); for (I = count; I> 0; I --) marry [I] = substr (str, int (rand () * len), 1); for (I = count; I> 0; I --) printf ("% c", marry [I]); printf ("\ n"); for (I = 0; I <= count; I ++) printf ("% c", marry [I]); printf ("\ n")} '8387055078385. how to view the status of the current Linux system, such as CPU usage, memory usage, and load. 5. in Linux, "/proc" is a pseudo-file directory, which does not occupy system space and reflects the current process of memory usage in a timely manner ...... many of these files store the system running status and related information. for files in "/proc", you can use the file view command to browse its content. The file contains the system-specific Information: cpuinfo host CPU information filesystems file system information meninfo host memory information version Linux memory version information diskstatus disk load information other top commands can dynamically display the current system process User usage, in addition, it is dynamically displayed, especially when the command displays a summary of the above system conditions. the free command can be used to view the actually used memory. Generally, use free-m to use lsof and ps-aux to view the detailed usage of each process. dmesg is also a commonly used command to view system performance # Question: ten monitored hosts and one monitor machine write scripts on the monitor machine. Once the availability of a monitored machine/partition is greater than 80%, an alert is sent to the crontab, check once every 10 minutes # Test Machine: Virtual Machine Linux as 4 #1. first, establish the trust relationship between servers. Use two machines to test the local ip address: 192.168.1.6 [root @ codfei ~] # Ssh-keygen-t rsaGenerating public/private rsa key pair. enter file in which to save the key (/root /. ssh/id_rsa):/root /. ssh/id_rsa already exists. overwrite (y/n )? Y (thought I had established the relationship for 2nd times, so here I overwrite the original file) Enter passphrase (empty for no passphrase) :( press Enter directly without entering the key) Enter same passphrase again: your identification has been saved in/root /. ssh/id_rsa.Your public key has been saved in/root /. ssh/id_rsa.pub.The key fingerprint is: 04: 37: 13: 2a: 4b: 10: af: c1: 2b: 03: 3f: 6b: 27: ce: b9: 62 root @ codfei [root @ codfei ~] # Cd. ssh/[root @ codfei. ssh] # ll-rw ------- 1 root 883 Apr 25 id_rsa-rw-r -- r -- 1 root 221 Apr 25 id_rsa.pub-rw-r -- r -- 1 root 442 Apr 25 known_hostsid_rsa is the key file, id_rsa.pub is a public key file. [Root @ codfei. ssh] # scp id_rsa.pub192.168.1.4:/root /. ssh/192.168.1.6root@192.168.1.4's password: id_rsa.pub 100% 221 0.2KB/s here the public key file named the local ip address is to establish trust relationships with more machines in the future without confusion. Log on to the host 192.168.1.4 [root @ codfei ~] # Cd. ssh/[root @ codfei. ssh] # cat 192.168.1.6> authorized_keys, then return to the host 192.168.1.6 and directly [root @ codfei. ssh] # ssh 192.168.1.4Last login: Wed Aug 8 12:14:42 2007 from 192.168.1.6, which occasionally involves permission issues. General. the/ssh folder is 755 with authorized_keys 600 or 644 ##### script ########################! /Bin/bash # SCRIPT: df_check.sh # Writeen by codfei Mon Sep 3 07:25:28 CST 2007 # PURPOSE: This script is used to monitor for full filesystems. ################ ######################## FSMAX = "80" remote_user = 'root' ##### complete you do not need to use rootremote_ip = (192.168.1.5 192.168.1.6 192.168.1.7 192.168.1.8 192.168.1.9192.168.1.10 192.168.1.11 192.168.1.12 192.168.1.13 192.168.1.14) ----> enter the information you want to monitor. Host ipip_num = '0' while ["$ ip_num"-le "$ (expr $ {# remote_ip [@]}-1) "] doread_num = '1' ssh" $ remote_user "@" $ {remote_ip [$ ip_num]} "df-h>/tmp/diskcheck_tmpgrep '^/dev/*'/tmp /diskcheck_tmp | awk '{print $5}' | sed's/\ % // g'>/tmp/diskcheck_num_tmpwhile ["$ read_num"-le $ (wc-l </tmp/diskcheck_num_tmp)] dosize = $ (sed-n "$ read_num" 'P'/tmp/diskcheck_num_tmp) if ["$ size"-gt "$ FSMAX"] then $ (grep '^/dev /*' /Tmp/diskcheck_tmp | sed-n $ read_num 'P'>/tmp/disk_check_mail) $ (echo $ {remote_ip [$ ip_num]}>/tmp/disk_check_mail) $ (mail-s "diskcheck_alert" admin </tmp/disk_check_mail) firead_num = $ (expr $ read_num + 1) doneip_num = $ (expr $ ip_num + 1) done ############## over ######################### ####################### run the script every ten minutes ########### # Add 0/10 ***/home/codfei/diskcheck to the cron table. sh 2> & 1 ##################### ######################################## ############ For example, if the ext2 file system is abnormal and crashes, how does one fix the file system when it is started? If an abnormal shutdown occurs, such as power failure, after the data center is notified to the user, we need to remotely repair and check all partitions except/partition in the file system: after the umount/homefsck-y/home/partition needs to be turned on, the data center personnel will scan and then log on and scan other partitions such as/home to view the file handle used by a process? You can check the/proc/process number/fd/number. for example, you can check the number of apache processes. [root @ localhost fd] # ps-ef | grep httpd | wc- how does l1 count the number of workers per second in apache? Tail access_log | awk '{print $1, $4} '[root @ localhost logs] # grep-c 'date-d' 3 second ago' + % t' access_log0 ############ #################################### 1./proc the role of the/sys subdirectory is to report different kernel parameters, and allows you to change some of them interactively. Unlike all other files in/proc, some files in this directory can be written, but this is only for root. The detailed list of directories and files occupies too much space, and the contents of this directory depend on the system. most files are only useful for some special applications. However, the following are two of the most common uses of this subdirectory: allow routing: even the default kernel of Mandrakelinux allows routing, you must explicitly allow it to do so. To do this, you only need to enter the following command as root: $ echo 1>/proc/sys/net/ipv4/ip_forward. if you want to disable routing, change 1 in the preceding command to 0. Blocking IP spoofing: IP spoofing can make people think that a certain packet from the outside is from the interface it arrives. This technology is often used by hackers (cracker. You can enable the kernel to prevent such intrusion. Enter $ echo 1>/proc/sys/net/ipv4/conf/all/rp_filter to prevent this attack. These changes are only valid when the system is running. After the system is restarted, they change their default values. To change these values at startup, you can add the command you typed at the shell prompt to/etc/rc. d/rc. local to avoid entering them each time. Another method is to modify/etc/sysctl. conf2, merge the odd and even rows of a text, merge rows 2nd and 3rd [root @ localhost bin] # cat 148 Oct 3bc1997 lpas 68.00 lvx2a 138484 Jan 78.00 SDF1 usp 344483 deiv 37.00 nov 7pl1998 usp 644320 kvm9d 83.00 aug der9393 psh 293231 wiel jul sdf9dsf sdfs 99.00 werl 223230 nov 19dfd9d abd 87.00 sdiv 230219 sept 5ap1996 usp 65.00 lvx2c 189216 Sept 3zl1998 usp 86.00 kvm9e 234 [root @ localhost bin] # sed '$! N; s/\ n // g' 148 Oct 3bc1997 lpas 68.00 lvx2a 138 Jan 484 SDF1 usp 78.00 deiv 344483 nov 7pl1998 usp 37.00 kvm9d 644 320 aug der9393 psh 83.00 wiel 293231 jul limit sdfs 99.00 werl 223 230 nov 19dfd9d abd 87.00 sdiv 230219 sept 5ap1996 usp 65.00 lvx2c 189 216 Sept 3zl1998 usp 86.00 kvm9e 234 [root @ localhost bin] # sed-n-e 2 p-e 3 p 1 | sed '$! N; s/\ n // '2017 Jan 484 SDF1 usp 78.00 deiv 344 483 nov 7pl1998 usp 37.00 kvm9d 6443. the read command automatically exits after 5 seconds. [root @ localhost bin] # read-t 54 automatic ftp upload #! /Bin/shftp-n < Chmod + x autoaddusr./autoaddusr8. what capabilities do individuals need to strengthen in planning the future of their work. First of all, I have a sincere heart, calm and calm, don't worry, don't worry; second, I have the corresponding professional knowledge and work experience. More than a year of system management experience has trained my business capabilities in this industry, and I have a corresponding understanding of the industry's prospects and development trends. finally, I will prove my abilities in my future work with my steadfast style! 9. what do daily monitoring tasks need to be monitored? 1) hardware: CPU:/proc/cpuinfo memory:/proc/meminfo hard disk: fdisk-l2) system: load:/proc/loadavguptime view real-time load average and swap virtual memory: vmstat (parameter-s; 2 4) SUID, user, process system log: tail-f/var/log/messageslogwatch -- print -- range Today -- service SSHD -- service pam_unix3) network: host_Alive, Ping, port, connection 1. how can I forward requests from Port 80 to port 8080? the current host IP address is 192.168.16.1, and the local Nic eth0:: # iptables-t nat-a prerouting-d 192.168.16.1-p tcp -- dport 80-j DNAT -- to192.168.16.1: 80 80 or: # iptables-t nat-a prerouting-I eth0-d 192.168.16.1-p tcp-m tcp -- dport80-j REDIRECT -- to-ports 80802. what is NAT? what are the differences between DNAT and SNAT? what are the application cases? 3. What is the difference between the packet filtering firewall and the proxy application firewall? can you list several products? 4. whether iptables supports time control of user behavior. if so, write down step 5. let's talk about the linux/unix versions you know. 6. list common linux Packaging tools and write the corresponding decompression parameters (at least three) 7. we plan to restart the server at every Sunday. how can we achieve this? 8. list the software used as a complete email system. for example, if a user enters a website g in a browser, what procedures have the computer explained to dns? Note: The local dns and local dns are not cached yet. A:. enter the URL in the browser B. the browser sends DNS request information c. the computer first queries the HOST file of the local machine to check whether the HOST file exists. if the HOST file exists, the system returns the result directly. if the HOST file does not exist, continue to step d. the computer queries the IP address result from the valid DNS server in the order of the local dns. valid dns returns the dns result to the local dns. The local dns caches the result until the TTL expires. returns the IP address to the browser g. the browser obtains page 10 based on IP information. we all know that dns uses both the tcp protocol and the udp protocol. When does it use the tcp protocol? When will udp be used? Why is it designed like this? A: There are many things to understand about this question. a: The maximum packet length of UDP is 65507 bytes, when responding to a dns query, the data packet length exceeds 512 bytes, and only the first 512 bytes are returned. in this case, the name interpreter usually uses TCP to send the original request. B. from the protocol itself: in most cases, UDP is used. we all know that UDP is an unreliable protocol. dns is not like other Internet applications that use UDP (for example: TFTP, BOOTP, SNMP, etc.), most of which are concentrated in the LAN. dns query and response must go through the WAN. the uncertainty of packet loss and round-trip time is greater in the Wan than in the LAN, this requires the dns client to require a good retransmission and timeout algorithm. at this time, TCP11 is used, an EXT3 file partition, and touch test is used. an error is reported when the file command is used to create a new file. the error message is that the disk is full, but the df-h command is used to view the disk size. only 60% of the disk space is used, why is this happening? let's talk about your reasons. A: either the disk quota or the EXT3 file system is not suitable for large files and small files, when many small files appear, inode may be exhausted. 12. we all know that the FTP protocol has two working modes. what is their approximate workflow? Two FTP working modes: Active FTP and Passive FTP, the FTP client randomly opens a port n greater than 1024 to initiate a connection to PORT 21 of the server, opens port n + 1 for listening, and sends the port n + 1 command to the server. After receiving the command, the server uses its local FTP data port (usually 20) to connect to the specified port N + 1 of the client for data transmission. In passive mode, the FTP client randomly opens a port N greater than 1024 to initiate a connection to Port 21 of the server, and opens port N + 1. Then, send the PASV command to the server to notify the server that it is in passive mode. After receiving the command, the server opens a port p greater than 1024 for listening, and then uses the port p command to notify the client that its own data PORT is P. After receiving the command, the client connects to port P of the server through Port N + 1 and transmits data between the two ports. In general, active FTP refers to the data port on which the server actively connects to the client, and Passive FTP refers to the data port on which the server passively waits for the client to connect to itself. In passive mode, FTP is usually used when FTP customers in the firewall access the external FTp server, because in this case, the firewall is usually configured to not allow external access to the host after the firewall, only connection requests initiated by hosts after the firewall are allowed to pass. Therefore, in this case, FTP transmission in active mode cannot be used, while FTP in passive mode can work well. 13. write a shell script to transfer files larger than 10 kb in the current directory to the/tmp Directory #/bin/sh # Programm: # Using for move currently directory to/tmpfor FileName in 'ls-l | awk '$5> 10240 {print $9} ''domv $ FileName/tmpdonels-al/tmpecho" Done! "14. apache has several working modes, which respectively introduce their features and describe how to use different working modes? Apache has two working modes: prefork (default installation mode of apache) and worker (you can add the parameter -- with-mpm-worker to select the working mode during compilation) prefork features: (pre-derived) 1. this mode eliminates the need to generate new processes when requests arrive, thus reducing system overhead 2. can prevent accidental memory leakage 3. when the server load drops, the number of sub-processes is automatically reduced. the worker feature is: multi-path processing module supporting mixed multi-thread and multi-process Processing. if a high-traffic HTTP server is, worker MPM is a good choice, because workerMPM occupies less memory than prefork. 15. Glossary HDLC, VTP, OSPF, RIP, DDOS, systemV, GNU, netscreen, ssh, smartd, apache, WAIT_TIME, etc. 16. write a shell script to get the network address of the local machine. For example, if the ip address of the local machine is 192.168.100.2/255.255.255.0, its network address is 192.168.100.1/255.255.255.0. Method 1: 1 .#! /Bin/bash2. # This script print ip and network3. file = "/etc/sysconfig/network-scripts/ifcfg-eth0" 4. if [-f $ file]; then5. IP = 'grep "IPADDR" $ file | awk-F "=" '{print $2}' 6. MASK = 'grep "NETMASK" $ file | awk-F "=" '{print $2}' 7. echo "$ IP/$ MASK" 8. exit 19. fi Method 2: 1. #! /Bin/bash2. # This programm will printf ip/network3. #4. IP = 'ifconfig eth0 | grep 'inet '| sed's/^. * addr: // g' | sed's/Bcast. * $ // g''5. NETMASK = 'ifconfig eth0 | grep 'inet '| sed's/^. * Mask: // g'' 6. echo "$ IP/$ NETMASK" 7. exit
Related Article

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.