Linux Interview and maintenance problem

Source: Internet
Author: User
Tags fpm log log svn iptables set up email nginx reverse proxy

    1. How do I change the of all. conf files under/home/example/to DB01 in non-interactive mode?
 find/home/example/-type f-name "*.conf"-print|xargs sed-i ' s/192\.168\.0\.2/db01/g '
    1. Write Iptables rule, only allow remote host to access native 22,80, port 443
 iptables-a input-p tcp-m multiport--dport 22,80,443-j ACCEPTiptables-a output-p tcp-m multiport--sport 22,80,443-j ACCEPT iptables-p INPUT DROPiptbales-p Forwad DROPiptbales-p OUTPUT DROPThen, extract the fifth field with a ":" Split?
    1. Nginx configuration file after modification, without affecting the online access, with what command to check file syntax errors and smooth restart Nginx
      /usr/local/nginx/sbin/nginx-s Reload
    1. Extract rows from the Bytu.log file that contain "WARNING" or "ERROR" without "Ignor", and then extract: the fifth field of the split
cat Bytu.log |grep-e ' warning| ERROR ' |grep-v ' Ignor "|awk-f: ' {print $} '5.StatisticsBytu.log in the log eachIPnumber of visits to the address, please count the trafficTenA. The log sample is as follows:[02/jul/2016-23:22:22 +0800]-get/htpp/1.1 cat bytu.log| awk ' {print $} ' |uniq-c |sort-rn|head-n6.write a script to judge172.17.111.0/24Network, whichIPcan bePingPass#!/bin/bash For i in ' seq 1 255 ';d o ping-c 1 172.17.111. $i &>/dev/null if [$?-eq 0]; Thenecho "172.17.111. $i OK"Elseecho "172.17.111. $i Error"fi Done
  1. .Suppose you have a name ' abc ' table, which has multiple fields, such as ' Createtime ' and the ' engine '. Name is engine The fields are represented by the ' Memoty ' and the ' MyIsam ' Two types of values are composed. How to List only ' Createtime ' and the ' engine ' these two columns and engine the value is ' MyIsam '?
Select Createtime, engine from ABC where ENGINE=MYISAM
    1. Configure the Nginx * Server access agent to the backend server, Access jump to and allow only network segment access.
Server{Listen;server_name *; Location /{rewrite/test.html Permanent;Proxy_pass;proxy_set_header Host $host;Allow;deny all;}}
    1. In what case there will be a 403,503,502,500 error, roughly describe
403 (user authentication denied) 404 (file Not found) 500 (server program problem) 502 (Nginx request backend PHP not found) 503 (appears on Squid,vanish agent software, proxy server access back-end server error) 504 (MySQL data has a delay)
    1. Write a view local Concurrent connection command and remove the number of connected IP rank
netstat-nat|grep-i "|wc-l "netstat-ntu | grep estab | awk ' {print $} ' | cut-d:-f1 | sort | uniq-c | Sort-nr 
    1. How Linux hangs in a shared directory under Windows
shut down the Windows and Linux firewalls;To create a shared directory on a Windows system share, note to modify the properties of this directory for sharing;create/windows directory on Linux system, chmod 777/windows;mount-t CFIs//windowsip/share//windows
    1. All. SVN folder totals Occupy disk size in the statistics directory A
Find directory A-name "*.SVN"-type D|xargs du-ch |tail-n1|awk ' {print $} '
    1. Crontab mistakenly deleted, how to recover? What should we do to prevent crontab from being mistakenly deleted?
recover the crontab run log from/var/log/cron in the last few days, in order to prevent crontab mistakenly delete, can backup to Crontab daily, back up the last 15 days of data, expired purge.


date=$ (Date +%y%m%d)

Crontab-l >/home/work/bak/crontab_$date.bak

find/home/work/bak/-mtime +15-name ' *.bak '-exec rm-rf {} \;

    1. The root user runs the script/opt/case/ under the httpd user, how does a command work?
sudo httpd php-f/opt/case/
    1. How do I see which files are open for a process with process number 4044?
Execute lsof-c programe-name or lsof-p through the process name and PID $pid(the LOSF command is useful lsof/proc view the process information that is opened for a file; Losf-i:25 view the process of listening on port 25; Losf-i @ View the link of the activity; losf-u Root View a user's Open text Pieces.) 
    1. How MySQL authorizes and cancels the authorization, if the environment is as follows:
Authorized ip: User name: Test password: 123456 database name: Monitor permissions: SELECTGrant SELECT privileges on monitor.* to ' test ' @ identified by ' 123456 ';flush Privileges;Revoke Select privileges on monitor.* to ' test ' @ identified by ' 123456 ';flush Privileges; 
    1. Linux How to view user log log
    1. What would you do if you were in charge of monitoring the system? 、
monitor MySQL master-slave, send mail when synchronization is abnormal. Depending on the number of web logs or network connections, monitor the number of concurrent connections for an IP or PV reaches 100 in a short time, i.e. iptables-i input-s DROP monitoring frequency 3 minutes. multi-clock monitoring of Web service status, such as: monitoring the Web site directory for malicious tampering, timing curl site return 502,ddos attack Detection fact traffic, traffic in and out of the size, the number of packets in and out, high latency, accompanied by packet loss phenomenon. database slow log detection, detection of log utilization, monitoring table space usage and remaining space, detection throughput, number of user connections, disk read and write total time, cache hit rate. use NC commands to simulate whether the Web client detects memcache, monitor response time, and hit rate.  
    1. Website PV from 100w burst to 1000w, what would you do
Page Click Burst, there may be malicious attacks, first check the access log for a short period of time to access the largest remote address, and to view the IP address location information, statistics the maximum number of visits to the page, according to the page to see which page to jump over, further PV authenticity, taking into account the server load iptables Block the high-volume client with low authenticity.  can consider consulting the market department, whether there is a part of the site to promote, whether the hot search, of course, through the access log can also determine the approximate reason.  
    1. What is the main reason for MySQL master-slave delay, how to solve? Master-Slave delay is a very normal thing, the first to analyze the cause of the principal and subordinate delay, mainly network, disk IO two major reasons. We need to reduce latency as much as possible, so we need to stabilize the network environment, use gigabit network cards and do two-card binding, and even use optical fiber communication, that is, do not let the network bandwidth transmission data bottleneck. On disk IO, you also need to upgrade, such as using high-speed high-cache hard disk and do RAID50, or use SSD hard disk and do RAID50, greatly improve the disk IO speed.
    1. Write a script background monitoring php-fpm process, when the process is detected to stop, can automatically start PHP-FPM
#!/bin/bashpid= ' pgrep php-fpm|wc-l 'if [$pid-eq 0];thenecho "PHP has down ..."echo "Wait a minute, php'll start ..."systemctl start php-fpmElseecho "PHP is well"fi
    1. There is a log file that assumes that the file name is Demo.log, and that it only looks at lines 1000th through 2000.
sed-n ' 1000,2000 ' P demo.log
    1. If you managed to manage the number of 100+ servers, how would you manage them?
1. First, the 100+ server is entered into the asset management system, and the use of Zabbix to add monitoring, set up email alerts. 2. Group 100+ machines According to business, such as database, test, etc.
    1. Use the automated management Tools Ansibel for batch management.
    1. Write a script to back up and package the database to the remote server directory.
#!/bin/bash mysqldump-uroot--all-database > All.sql if [$!-eq=0] Then /usr/bin/tar-zcvf ' Date +%f '. tar.gz all.sql /usr/bin/rsync-az ' Date +%f '. tar.gz Else echo "mysqldump failure" >>/tmp/mysqldump.logfi 
    1. Use Tcpdump to monitor the host IP to, TCP port 80 data, and output the results to Tcpdump.log, please write the relevant commands.
TCPDUMP-NN host and TCP and port 80-w tcpdump.log
    1. Use SED to modify Test.txt's 23 line test to Tset;
 sed-i "23s/test/tset/g" Test.txt
    1. Write a script to implement the bulk add 20 users, the user name is user1-20, password is user followed by 5 random characters.
#!/bin/bash For i in ' seq 1 ' Do Useradd user_$ipassword= ' echo $RANDOM |md5sum|cut-c 1-5 'password= "User" $passwordecho $password |passwd--stdin user_$i  Done~       
    1. Write a script to determine if a specified script has a syntax error, and if there is an error, remind the user to type Q or Q to ignore the error and exit any other key to open the specified script via vim.
#!/bin/bash script_file= "./"sh-n $script _file >/dev/null 2>/dev/null n= ' echo $? 'if [$n-ne 0];then Read-p "This script was a bad file," q "or" Q "--exit,other key to edit the file:" KeyEcho $keyif [$key = = ' Q '-o $key = = ' Q '] ThenExitElseVI $script _filefi fi   #!/bin/bash script_file= "./"sh-n $script _file >/dev/null 2>/dev/null n= ' echo $? 'if [$n-ne 0];then Read-p "This script was a bad file," q "or" Q "--exit,other key to edit the file:" KeyCase $key inq| Q)Exit 0     ;;   *)VI $script _file     ;;Esacfi
    1. Take a random number within 1-39
echo $[$RANDOM%39]
    1. Display/etc/inittab begins with #, followed by one or more whitespace characters and followed by any non-whitespace character line
grep "^# \{1,\}[^]"/etc/inittab
    1. 32-bit random password generation under shell
echo $RANDOM |md5sum|cut-c 1-32
    1. Use the awk command to calculate the sum of the file sizes in a directory
ls-l/root |awk ' {sum=sum+$5} END {print sum} '
    1. Now the company has such demand, will nginx reverse proxy Apache, known as Apache address:, proxy link for Curl:,nginx How to configure the implementation of this feature?
server {Listen;server_name;Location /{Proxy_pass;proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header x-real-ip $remote _addr;
proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
#client_max_body_size 100m;} 34--use any of the scripts you are familiar with To do the following: Take out the first column of/etc/passwd, and each column is described in a row as: "The 1 account is Aowgamecoser" to show that 1 represents the number of rows.Cat etc/passwd | awk-f ': ' {print ' the ' NR ' account is Aowgamecoser ', $ '
    1. If we deployed in the Beijing BGP line Room Armor Storm game, 23:00 in the evening to receive complaints Shenzhen region some players can not log in the game, please summarize the troubleshooting ideas and solutions.
    1. Check whether the network is normal, you can view the Shenzhen to Beijing BGP computer room This network
    2. Check the operation of the server, whether the load is too high, memory ran full.
    3. View error Log
    1. One day with the user complained to visit the site is slow or the page can not open, if you are the webmaster of the Web server, how do you find the reason,
Check the amount of online users of the site, based on the user's concurrency to make a preliminary decision is not because of excessive concurrency caused by the database connection load causeCheck that the database connection is fully loaded. The browser's own detection request is sent to the return time to determine if the user bandwidth is the reason.
    1. Write an sed command, modify the contents of the/tmp/input.txt file, request: Delete all empty lines, add a "AAA" to the non-empty line, and add a "BBB" at the end of the row
sed '/^$/' d 1.tx|sed ' s/$/bbb/' |sed ' s/^/aaa/'

Linux Interview and maintenance problem

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.