锁屏面试题百日百刷,每个工作日保持更新面试题。请看到最初就能获取你想要的, 接下来的是今日的面试题:
1.Linux常用命令**
参考答案:find、df、tar、ps、top、netstat等。(尽量说一些高级命令)
2.Linux查看内存、磁盘存储、io 读写、端口占用、过程等命令**
答案:
1、查看内存:top
2、查看磁盘存储状况:df -h
3、查看磁盘IO读写状况:iotop(须要装置一下:yum install iotop)、iotop -o(间接查看输入比拟高的磁盘读写程序)
4、查看端口占用状况:netstat -tunlp | grep 端口号
5、查看过程:ps aux
3.应用Linux命令查问file1中空行所在的行号**
答案:
[root@hadoop102 datas]$ awk '/^$/{print NR}' file1.txt
5
4.有文件chengji.txt内容如下:**
张三 40**
李四 50**
王五 60**
应用Linux命令计算第二列的和并输入**
[root@hadoop102 datas]$ cat chengji.txt | awk -F " " '{sum+=$2} END{print sum}' 150
5.Shell脚本里如何查看一个文件是否存在?如果不存在如何解决?**
!/bin/bash
if [ -f file.txt ]; then
echo "文件存在!" else
echo "文件不存在!"
Fi
6.用Shell写一个脚本,对文本中无序的一列数字排序**
[root@hadoop102 ~]# cat test.txt # 1-10
[root@hadoop102 ~]# sort -n test.txt|awk '{a+=$0;print $0}END{print "SUM="a}' SUM=55
7.请用Shell脚本写出查找以后文件夹(/home)下所有的文本文件内容中蕴含有字符”shen”的文件名称**
[root@hadoop102 datas]$ grep -r "shen" /home | cut -d ":" -f 1
/home/root/datas/sed.txt
/home/root/datas/cut.txt
全部内容在git上,理解更多请点我头像或到我的主页去取得,谢谢**