一、基础(每题 2 分)
1.1 阐述绝对路径与相对路径的区别
1.2 简述软连接与硬连接的区别
1.3 简述命令执行的流程
1.4 写出查询 file.txt 以 abc 结尾的行
1.5 查找 file.log 文件中的包含关键字“helloworld”的内容,及其上下两行的重定向到 1.txt
1.6 假设公司研发部的用户 David 和 Peter 属于组 A
1.6.1 建立相应的用户和组,并设置相应的对应关系
1.6.2 建立目录 yf_a,该目录里面的文件只能由研发部人员读取、增加、删除、修改以及执行,其他用户不能对该目录进行任何操作
1.6.3 建立目录 yf_b,该目录里面的文件只有研发部的 David 拥有所有权限,研发部的其他人只有查看权限,其他部门不能进行任何操作
1.7 有一用户 oldboy,及用户组 oldboy,在 code目录下创建的所有文件自动归属于 oldboy 组所有
1.8 有两个用户组 python 及 Linux,python 组可以修改读取/hom/python/目录下所有内容,但不能让 Linux 组读取;Linux 组可以修改读取/home/linux/目录下所有文件,但不能让 python组读取。给出配置命令。
二、find 相关(每题 3 分)
2.1 找出/tmp 目录下,属主不是 root 的文件
find /tmp -type f ! -name root
2.2 查找/var 目录下属主为 old,且属组为 boy的文件
find /var -tupe f -user old -group boy
2.3 查找/var 目录下 7 天以前修改、且属组为root 的文件
find /var -type f -group root -mtime +7
2.4 查找/etc 目录下大于 1M 且类型为普通文件的所有文件
find /etc -type f -size +1M
2.5 查找/etc/目录下大于 100k,小于 1M 的文件
find /etc -type f -type f -size +100k -size +1M
2.6 查找/目录下文件名包含 txt 的文件
find / -type f -name "*txt*"
2.7 查找/目录下属主是 oldboy 或者属主是oldgirl 的文件
find / -type f -user oldboy -o -user oldgirl
2.8 删除/tmp 目录下 15 天前的文件
find /tmp -type f -mtime +15 -delete
2.9 查找根下名为 1.txt 或 2.txt 的文件
find / -type f -name "1.txt" -o -name "2.txt"
2.10 查找/tmp 目录下所有文件并删除
find /tmp -type f -delete
三、tar 相关(每题 3 分)
3.1 使用 zip 打包/etc 目录。
zip -r etc.zip /etc
3.2 用 zip 打包/opt 目录,要求不显示打包过程。
zip -qr opt.zip /opt
zip -r opt.zip /opt > 1.txt
3.3 解压/data/etc.zip 到当前目录
unzip /data/etc.zip
3.4 已知文件 oldboy.zip,在不解压的情况下,如何查看该文件的内容。
unzip -l oldboy.zip
3.5 将/data/old.tar.gz 解压到/opt 目录下
tar xf /data/old.tar.gz -C /opt/
3.6 不解压的情况下,查看/data/old.tar.gz 压缩包中都有什么内容
tar tf /data/old.tar.gz
3.7 打包/etc/目录,要求不打包/etc/hosts 这个文件。
tar czf etc.tar.gz /etc/ --exclude=etc/hosts
tar czf etc.tar.gz /etc/ --exclude etc/hosts
vim 1.txt
etc/hosts
tar czXf 1.txt etc.tar.gz /etc/
3.8 打包/etc/目录,要求不打包/etc/hosts 和/etc/passwd 这两个文件。
tar czf etc.tar.gz /etc/ --exclude=etc/hosts --exclude=etc/passwd
tar czf etc.tar.gz /etc/ --exclude etc/hosts --exclude etc/passwd
vim 1.txt
etc/hosts
etc/passwd
tar czXf 1.txt etc.tar.gz /etc/
3.9 打包/etc/目录,命令以 ip 地址方式的压缩包: 比如: 10.0.0.200_etc.tar.gz
ifconfig ens33 |awk 'NR==2{print $NF}'
tar czf $(ifconfig ens33 |awk 'NR==2{print $NF}')_etc.tar.gz /etc
3.10 打包/etc/目录,要求以.bz2 格式
tar cjf etc.tar.bz2 /etc
四、软件安装相关(每题 3 分)
4.1 使用 rpm 命令安装 tree 软件。
rpm -ivh tree
4.2 查看你的服务器中是否安装 httpd 这个软件。
rpm -q httpd
4.3 查看 httpd 软件包里面的内容。
rpm -ql httpd
4.4 查看 httpd 软件包的详细信息。
rpm -qc httpd
4.5 查看一下 netstat 这个命令属于哪个软件包
yum provides netstat
rpm -qf $(where netstat)
4.6 卸载 sl 这个命令
rpm -e sl
yum remove sl
4.7 已知服务的 mongodb 的版本为 3.0,现将mongodb 这个软件版本升级为 4.0,请给出 rpm升级命令
rpm -Uvh mongodb
yum update mongodb
4.8 yum 安装 rsync 这个软件。
yum provides rsync
yum install rsync -y
4.9 yum 安装多个软件,例如 sl、lsof、nettools、nmap 等
yum install sl lsof nettools nmap -y
4.10 查看你的服务器中有哪些可用的 yum 源仓库。
yum repolist all
五、进阶(每题 4 分)
5.1 将“I am student”重定向到/root/bgx1.txt 中
echo "I am student" > /root/bgx1.txt
5.2 简述源码编译的流程
5.3 查找/etc/目录下以.conf 结尾、修改时间为最近七天的文件,打包压缩为/tmp/conf.tar.gz
find /etc -type f -size +7 -name "*.conf"
tar czf /tmp /conf.tar.gz $(find /etc -type f -size +7 -name "*.conf")
5.4 查找/目录下以 a 开头的目录,打包压缩为zip 结尾的压缩包
find / -type d -name "a*"
zip -r opt.zip $(find / -type d -name "a*")
5.5 查找/目录下,属主为 oldboy 的文件,复制到/home/oldboy/目录下
find / -type f -name oldboy -exec cp {} /home/oldboy \;
六、翻译(每题 2 分)
6.1 [root@test-200 ~]# cd /rot -bash: cd: /rot: No such file or directory
6.2 [root@test-200 ~]# mdkir a -bash: mdkir: command not found
6.3 [root@test-200 ~]# mkdir a mkdir: cannot create directory ‘a’: File exists
6.4 [root@test-200 ~]# rm a rm: cannot remove ‘a’: Is a directory
6.5 [root@test-200 ~]# rm a.txt rm: remove regular empty file ‘a.txt’?
6.6 [root@test-200 ~]# cp /tmp/a.txt /root/a.txt cp: overwrite ‘/root/a.txt’?
6.7 [root@test-200 ~]# id www id: www: no such user
6.8 [test@test-200 /]$ cd /root bash: cd: /root: Permission denied
6.9 [root@test-200 /tmp]# cp -q a.txt c.txt cp: invalid option -- 'q'
6.10 [root@test-200 /home]# useradd test useradd: user 'test' already exists
网友评论