【Linux面试】-(腾讯,百度,美团,滴滴)

文章目录


Linux 面试题-(腾讯,百度,美团,滴滴)

  1. 分析日志 t.log(访问量),将各个 ip 地址截取,并统计出现次数,并按从大到小排序(腾讯)
    http://192.168.200.10/index1.html
    http://192.168.200.10/index2.html
    http://192.168.200.20/index1.html
    http://192.168.200.30/index1.html
    http://192.168.200.40/index1.html
    http://192.168.200.30/order.html
    http://192.168.200.10/order.html
    答案: cat t.txt | cut -d ‘/’ -f 3 | sort | uniq -c | sort -nr

  2. 统计连接到服务器的各个 ip 情况,并按连接数从大到小排序 (腾讯)
    netstat -an | grep ESTABLISHED | awk -F " " ‘{print $5}’ | cut -d “:” -f 1 | sort | uniq -c| sort -nr
    在这里插入图片描述
    在这里插入图片描述

  3. 问题:如忘记了 mysql5.7 数据库的 ROOT 用户的密码,如何找回? (滴滴)
    vim /etc/my.cnf
    追加一行: skip-grant-tables
    service mysqld restart
    空密码登录 mysql -uroot -p
    use mysql;
    update user set authentication_string=password(“newPassword”) where user=‘root’;
    flush privileges;
    exit;
    将 /etc/my.cnf 中追加的内容去掉.
    service mysqld restart
    使用新设置的密码登录mysql

  4. 写出指令:统计 ip 访问情况,要求分析 nginx 访问日志(access.log),找出访问页面数量在前 2 位的 ip(美团)
    cat access.log | awk -F " " ‘{print $1}’ | sort | uniq -c | sort -nr | head -2

  5. 使用 tcpdump 监听本机, 将来自 ip 192.168.200.1,tcp 端口为 22 的数据,保存输出到tcpdump.log , 用做将来数据分析(美团) >>
    在这里插入图片描述
    tcpdump -i ens33 host 192.168.200.1 and port 22 >> /home/tcpdump.log

  6. 常用的 Nginx 模块,用来做什么(头条)
    rewrite 模块,实现重写功能
    access 模块:来源控制
    ssl 模块:安全加密
    ngx_http_gzip_module:网络传输压缩模块
    ngx_http_proxy_module 模块实现代理
    ngx_http_upstream_module 模块实现定义后端服务器列表
    ngx_cache_purge 实现缓存清除功能

  7. 问题:列举 Linux 高级命令,至少 6 个(百度)
    netstat //网络状态监控 top //系统运行状态 lsblk //查看硬盘分区 find
    ps -aux //查看运行进程 chkconfig //查看服务启动状态 systemctl //管理系统服务器

  8. 问题:Linux 查看内存、io 读写、磁盘存储、端口占用、进程查看命令是什么?(瓜子)
    top, iotop, df -lh , netstat -tunlp , ps -aux | grep 关心的进程

  9. 使用 Linux 命令计算 t2.txt 第二列的和并输出 (美团)
    张三 40
    李四 50
    王五 60
    cat t2.txt | awk -F " " ‘{sum+=$2} END {print sum}’

  10. Shell 脚本里如何检查一个文件是否存在?并给出提示(百度)
    if [ -f 文件名 ] then echo “存在” else echo “不存在” fi

  11. 假如您需要找出 /etc/my.conf 文件属于哪个包 (package) ,您可以执行:
    A. rpm -q /etc/my.conf
    B. rpm -requires /etc/my.conf
    C. rpm -qf /etc/my.conf
    D. rpm -q | grep /etc/my.conf
    答案:C

  12. 请写出统计/home 目录下所有文件个数和所有文件总行数的指令(在金山面试题扩展)
    find /home/test -name “.” | wc -l
    find /home/test -name “.” | xargs wc

猜你喜欢

转载自blog.csdn.net/weixin_40293999/article/details/129881714