1. Write an sed command to modify the contents of the/tmp/input.txt file, requiring:
(1) Delete all empty lines;
(2) In a row, if you include "11111″", insert "AAA" in front of "11111″", insert "BBB" after "11111″", for example: Change the line with content 0000111112222 to: 0000aaa11111bbb2222
[Email protected]~]# cat-n/tmp/input.txt
1 000011111222
2
3 000011111222222
4 11111000000222
5
6
7 111111111111122222222222
8 2211111111
9 112222222
10 1122
11
Delete all empty line commands
[Email protected]~]# sed '/^$/d '/tmp/input.txt
000011111222
000011111222222
11111000000222
111111111111122222222222
2211111111
112222222
1122
Inserts the specified character
[Email protected]~]# sed ' s#\ (11111\) #AAA \1bbb#g '/tmp/input.txt
0000aaa11111bbb222
0000aaa11111bbb222222
aaa11111bbb000000222
aaa11111bbbaaa11111bbb11122222222222
22aaa11111bbb111
112222222
1122
2. Every Monday three o'clock in the afternoon the/tmp/logs directory below the suffix *.log all the files rsync sync to the same directory in the backup server 192.168.1.100, crontab configuration items how to write:
* * 1 rsync-avzp/tmp/logs/*.log [email protected]:/tmp/logs
3. Locate all normal files under the/tmp/directory whose names end with "_s1.jpg" and package them in the/tmp/back.tar.gz file if their modification date is within one day
Find/tmp-type f-name ". *_sj.jpg"-mtime 1|xarges tar zxf/tmp/back.tar.gz
4. Write how to add VirtualHost to Apache, so that when accessing http://www.test.com and http://www.test.cn, open the file under the/var/www/html directory:
ServerAdmin [email protected]
DocumentRoot "/var/www/html"
ServerName www.test.com
Serveralias test.cn
Errorlog "Logs/bbs-error_log"
Customlog "Logs/bbs-access_log" common
5. When configuring the MySQL server, configure the auto_increment_increment=3, what does the 3 mean?
Auto_increment is used for the primary key auto-growth, from 3 onwards, 3 for the self-increment of the starting value
6. Display the IP address of the local Eth0 network card with one command, no other characters are displayed
Method One:
[Email protected] ~]# ifconfig eth0|grep "inet addr" |awk-f ' [:]+ ' ' {print $4} '
192.168.1.22
Method Two:
[[email protected] ~]# ifconfig eth0|awk-f ' [:]+ ' nr==2 {print $4} '
192.168.1.22
Method Three:
[Email protected] ~]# ifconfig eth0|sed-n ' 2p ' |sed ' s#^.*addr:# #g ' |sed ' s# bc.*$# #g '
192.168.1.22
Method Four:
[[email protected] ~]# ifconfig eth0|sed-n ' 2p ' |sed-r ' s#^.*addr: (. *) Bc.*$#\1#g '
192.168.1.22
7. Please explain in detail how keepalived failover works
This failover is achieved through the VRRP protocol, the master node will send the heartbeat information at a certain time interval broadcast packet, tell the standby node's own survival status information, when the primary node fails, the standby node in a period of time to receive the broadcast packet, so as to determine the primary node failure, Therefore, it calls its own takeover program to take over the IP resources and services of the primary node, and when the primary node resumes, the standby node will actively release the resources and revert to the state before the takeover to achieve the primary and standby failover.
8. Write a curl command to access the following url:http://www.baidu.com/s?wd=test on the specified server 61.135.169.121, and the time-out for the access is 20 seconds:
Curl–connect-timeout Http://61.135.169.121/s?wd=test
9. With the netstat command with other shell commands, according to the source IP statistics all the established status links to 80 ports, the output is similar (the first column number of connections, the second column IP):
[Email protected]~]# Netstat-an|grep established
TCP 0 139.224.199.85:22 101.47.33.86:51763 established
TCP 0 0 139.224.199.85:45368 106.11.68.13:80 established
[[email protected] ~]# netstat-an|grep established|grep ": 80"
TCP 0 0 139.224.199.85:45368 106.11.68.13:80 established
[[email protected] ~]# netstat-an|grep established|grep ": 80″|awk ' begin{fs=" [[: Space:]:]+ '}{print $4} '
139.224.199.85
Description: FS is a field delimiter
If you need to organize and sort, the complete command is as follows
[[email protected] ~]# netstat-an|grep established|grep ": 80″|awk ' begin{fs=" [[: Space:]:]+ '}{print $4} ' |sort|uniq-c| Sort-nr
Linux system Operations Common interview brief Answer series (three) (9 questions)