1、请解释如下 cron6:
* * * * * test -f /etc/dAppCluster/gethits.py && /etc/dAppCluster/gethitspy > /dev/null 2>&1
20 4 * * * test -d /data1/www/logs && /usr/bin/find /data1/www/logs -name '*-error_log"-atime +7 -type f -exec rm -f f ; 2>&1
2、编写一个Shell脚本,功能是求出一个文本文件的行数、字数和字符数,并输出到屏幕上。假设该文本文件的路径是 /home/user/file.txt。
#! /bin/bash
file_dir="/home/admin/file.txt"
# 统计 -l行数 -w字数 -m字符数 -L最长一行长度
lines=$(wc -l < "$file_dir")
words=$(wc -w < "$file_dir")
characters=$(wc -m < "$file_dir")
# 输出结果
echo "行数: $lines"
echo "字数: $words"
echo "字符数: $characters"
3、添加用户 ambow,密码为123456的方法有:如何批量添加用户sgt110701-sqt110730
#! /bin/bash
useradd ambow
echo 12346 | passwd --stdin ambow
#批量添加用户
for ((i=1;i<=30;i++))
do
useradd sqt1107$i
done
4、 请写出iptables -AINPUT -p icmp -i cmp-type 8 -j ACCEPT这条命令的作用
5、集群内有300台主机,如果要收集所有主机的IP地址,可以通过什么工具或者命令实现?如果要将一个rm包上传至所有主机,可以通过什么工具或者命令实现?
6、请写出sed-n 1p testfile这个命令的作用
7、请以域名为维度实时(5S 一次)统计,apache 日志/var/log/httpd/access_log 的 http状态码及相应状态码的日志条数,输出的内容如下:
domianname httpcode counter
www.sina.com.cn 200 1000
www.sina.com.cn 503 100
www.sinacom.cn 200 500
sports.sina.com.cn 404 3
#! /bin/bash
while true
do
# 使用 awk 命令实时统计域名和状态码的计数
awk '{status[$11" "$9]++} END {for (domain in status) print domain, status[domain]}' /var/log/httpd/access_log > httpcode_counter.txt
# 输出结果表头
echo "domainname httpcode counter"
# 从 httpcode_counter.txt 文件中读取并输出统计结果
while IFS= read -r line
do
echo "$line"
done < httpcode_counter.txt
# 清空 httpcode_counter.txt 文件
> httpcode_counter.txt
# 等待5秒
sleep 5
done
8、用虚拟机安装了一台 Linux 系统,突然想克隆一台服务器,克隆后发现无法上网,如何解决?
9、 每次开机在/unp目录下创建一个当天的日期文件头提示:当前日期表示的方法为:date +%Y/em/ed)
#! /bin/bash
cat << end >/etc/rc.d/rc.local
dateStr=$(date +%Y/%m/%d)
echo "当前日期:$dateStr" > /unp/$dateStr.txt
end
chmod +x /etc/rc.d/rc.local
10、用tcpdump嗅操80端口的访看看谁最高
sudo tcpdump -i eth33 port 80 -nn -c <嗅探包数量> | awk '{print $3}' | sort | uniq -c | sort -nr