Linux Interview Quiz 8

Source: Internet
Author: User

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

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.