1. Write a script to find the last created time is three days ago, the suffix is *.log file and deleted.
Answer:
Find dir/-mtime +3-type f-name ". *.log"-exec rm-rf {} \;
2. Write a script to move files larger than 100k in a directory to/TMP.
Answer:
Find dir/-type f-size +100k-exec MV {}/tmp \;
3. Write a script to back up and package the database to the remote server 192.168.1.1/backup directory
Answer:
#!/bin/bash
/usr/local/mysql/bin/mysqldump-uroot--default-character-set=utf8-p ' * * * * database >/tmp/data_$ (Date +%F). sql
[$?-eq 0] && gzip/tmp/data_$ (date +%f). sql
[-f/tmp/data_$ (Date +%f). gz] && rsync-av-e "ssh-p"/tmp/data_$ (date +%f). gz [Email protected]:/backup/
4. Write a firewall configuration script that allows the remote host to access only the 80 port of the machine.
Answer:
#!/bin/bash
Iptables-f
Iptables-a input-p TCP--dport 80-j ACCEPT
Iptables-p INPUT DROP
Iptables-p OUTPUT ACCEPT
5. Write a script to perform nginx log statistics, get the top 10 IP access. (Nginx log path
Diameter:/home/logs/nginx/default/access.log)
Answer:
awk ' {print '} '/home/logs/nginx/default/access.log |sort-n|uniq-c|sort-rn|head
6. Write down the meanings of the following commands
Maxkeepalivrequest #最大允许多少个持久链接
Options followsymlinks #跟随符号链接, allowing access to the original file that the symbolic link points to. To be safe, you should not turn on
Order Deny Allow #先deny后allow
Deny from all #拒绝所有访问
Allow from 192.168.1.1 #只允许192.168.1.1 Access
7. Write a script to replace the/usr/local in the specified file with a different directory
Answer:
Sed-i ' s#/usr/local#/usr/src#g ' file
Linux Interview Quiz 8