一、基礎(chǔ)(每題 2 分)
1.1 闡述絕對(duì)路徑與相對(duì)路徑的區(qū)別
相對(duì)路徑:從當(dāng)前目錄開始的就是相對(duì)路徑
絕對(duì)路徑:從根開始的路徑就是絕對(duì)路徑
1.2 簡(jiǎn)述軟連接與硬連接的區(qū)別
ln 命令創(chuàng)建硬鏈接;ln -s 創(chuàng)建軟鏈接
目錄不能創(chuàng)建硬鏈接,硬鏈接不能跨越分區(qū)
目錄軟鏈接特別常用,軟鏈接支持跨分區(qū)
硬鏈接文件與源文件inode相同,軟鏈接文件與源文件inode不同
刪除軟鏈接對(duì)源文件及硬鏈接文件無影響
刪除硬鏈接對(duì)源文件及鏈接文件無影響
刪除源文件,對(duì)硬鏈接無影響,會(huì)導(dǎo)致軟鏈接失效
刪除源文件及其所有硬鏈接,文件會(huì)被真正刪除
1.3 簡(jiǎn)述命令執(zhí)行的流程
判斷命令是否是絕對(duì)路徑
判斷命令是否有別名
判斷命令是內(nèi)置命令還是外置命令
bash的內(nèi)部命令直接執(zhí)行,外部命令檢查是否有緩存
通過$PATH變量查找命令,有命令執(zhí)行,沒有命令報(bào)錯(cuò)'command not found
1.4 寫出查詢 file.txt 以 abc 結(jié)尾的行
grep 'abc$' file.txt
1.5 查找 file.log 文件中的包含關(guān)鍵字 “helloworld”的內(nèi)容,及其上下兩行的重定向到? 1.txt
grep -C2 'helloworld' 1.txt
1.6 假設(shè)公司研發(fā)部的用戶 David 和 Peter 屬于組? A
1.6.1? 建立相應(yīng)的用戶和組,并設(shè)置相應(yīng)的對(duì)應(yīng)關(guān)系
groupadd A
useradd David -G A
useradd Peter -G A
1.6.2? 建立目錄 yf_a,該目錄里面的文件只能由研發(fā)部人員讀取、增加、刪除、修改以及執(zhí) 行,其他用戶不能對(duì)該目錄進(jìn)行任何操作
mkdir yf_a
chown .A yf_a
chmod 770 yf_a
1.6.3? 建立目錄 yf_b,該目錄里面的文件只有研發(fā)部的? David 擁有所有權(quán)限,研發(fā)部的其他 人只有查看權(quán)限,其他部門不能進(jìn)行任何操作
mkdir yf_b
chown David.A yf_b
chmod 740 yf_b
1.7 有一用戶 oldboy,及用戶組 oldboy,在code 目錄下創(chuàng)建的所有文件自動(dòng)歸屬于? oldboy 組所有?
chmod g+s code
1.8 有兩個(gè)用戶組 python 及 Linux,python組可以修改讀取/tmp/python/目錄下所有內(nèi)容,但? 不能讓? Linux 組讀?。籐inux 組可以修改讀取 /tmp/linux/目錄下所有文件,但不能讓 python 組讀取。給出配置命令。
chown .python /tmp/python
chmod 770 /tmp/python
chown .Linux /tmp/Linux
chmod 770 /tmp/Linux
二、find 相關(guān)(每題 3 分)
2.1 找出/tmp目錄下,屬主不是 root 的文件
find /tmp -type f ! -user 'root'
2.2 查找/var目錄下屬主為 old,且屬組為 boy的文件
find /var -type f -user 'old' -group 'boy'
2.3 查找/var目錄下 7 天以前修改、且屬組為root 的文件
find /var -type f -mtime +7 -group 'root'
2.4 查找/etc目錄下大于 1M 且類型為普通文件的所有文件
find /etc/ -size +1M -type f
2.5 查找/etc/目錄下大于? 100k,小于 1M 的文 件?
find /etc/ -size +100k -size -1M
2.6 查找/目錄下文件名包含? txt 的文件
find / -type f -name '*txt*'
2.7 查找/目錄下屬主是? oldboy 或者屬主是 oldgirl 的文件
find / -type f -user 'oldboy' -o -group 'oldgirl'
2.8 刪除/tmp目錄下 15 天前的文件
find /tmp -type f -mtime +15 -exec rm -f {} ;
find /tmp -type f -mtime +15 | xargs rm -f
2.9 查找根下名為? 1.txt 或 2.txt 的文件
find / -name '1.txt' -o -name '2.txt'
2.10 查找/tmp 目錄下所有文件并刪除?
find /tmp -type f -exec rm -f {} ;
find /tmp -type f | xargs rm -f
三、tar? 相關(guān)(每題 3 分)
3.1 使用? zip 打包/etc 目錄。
zip -r ~/etc.zip /etc
3.2 用? zip 打包/opt 目錄,要求不顯示打包過程。
zip -rq ~/opt.zip /opt
3.3 解壓/data/etc.zip到當(dāng)前目錄
unzip /data/etc.zip
3.4 已知文件 oldboy.zip,在不解壓的情況下,如何查看該文件的內(nèi)容
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 包中都有什么內(nèi)容
tar tf /data/old.tar.gz
3.7 打包/etc/目錄,要求不打包/etc/hosts這個(gè)文件。
tar zcf etc.tar.gz --exclude /etc/hosts /etc
3.8 打包/etc/目錄,要求不打包/etc/hosts和/etc/passwd這兩個(gè)文件。
tar zcf etc.tar.gz --exclude /etc/hosts --exclude /etc/passwd /etc/
3.9 打包/etc/目錄,命令以ip 地址方式的壓縮包:比如:10.0.0.200_etc.tar.gz
tar zcf (ifconfig eth0 | awk 'NR==2 {print$2}')_etc.tar.gz /etc
3.10 打包/etc/目錄,要求以.bz2格式
tar Jcf etc.tar.bz2 /etc
四、軟件安裝相關(guān)(每題3 分)
4.1 使用rpm 命令安裝 tree 軟件。
rpm -ivh tree
4.2 查看你的服務(wù)器中是否安裝httpd 這個(gè)軟件。
rpm -q httpd
4.3 查看httpd 軟件包里面的內(nèi)容。
rpm -ql httpd
4.4 查看httpd 軟件包的詳細(xì)信息。
rpm -qi httpd
4.5 查看一下netstat 這個(gè)命令屬于哪個(gè)軟件包
yum provides netstat
rpm -qf $(which netstat)
4.6 卸載sl 這個(gè)命令
yum remove sl
rpm -e sl
4.7 已知服務(wù)的mongodb 的版本為 3.0,現(xiàn)將mongodb這個(gè)軟件版本升級(jí)為4.0,請(qǐng)給出 rpm升級(jí)命令
rpm -Uvh mongodb
4.8 yum 安裝 rsync 這個(gè)軟件。
yum install -y rsync
4.9 yum 安裝多個(gè)軟件,例如 sl、lsof、net-tools、nmap 等
yum install -y sl lsof net-tools nmap
4.10 查看你的服務(wù)器中有哪些可用的 yum 源倉(cāng)庫(kù)。
yum repolist?
五、進(jìn)階(每題4 分)
5.1 將“I am student”重定向到/root/bgx1.txt中
echo 'I am student' > /root/bgx1.txt
5.2 簡(jiǎn)述源碼編譯的流程
下載軟件包
./configure --prefix=/usr/local/nginx-1.16 ——生成mkefile文件
make ——編譯
make install ——安裝
5.3 查找/etc/目錄下以.conf結(jié)尾、修改時(shí)間為最近七天的文件,打包壓縮為/tmp/conf.tar.gz
find /etc/ -type f -name '*.conf' -mtime -7 -|xargs tar zcf /tmp/conf.tar.gz
5.4 查找/目錄下以a 開頭的目錄,打包壓縮為zip結(jié)尾的壓縮包
find / -type d -name 'a*' -exec zip a.zip {} ;
5.5 查找/目錄下,屬主為oldboy 的文件,復(fù)制到/home/oldboy/目錄下
find / -type f -user 'oldboy' -exec cp {} /home/oldboy
六、翻譯(每題2 分)
6.1 [root@test-200 ~]# cd /rot
-bash: cd: /rot: No such file or directory
沒有這個(gè)目錄
6.2 [root@test-200 ~]# mdkir a
-bash: mdkir: command not found
沒有mdkir這個(gè)命令
6.3 [root@test-200 ~]# mkdir a
mkdir: cannot create directory ‘a(chǎn)’: File exists
a目錄存在
6.4[root@test-200 ~]# rm a
rm: cannot remove ‘a(chǎn)’: Is a directory
a是個(gè)目錄
6.5 [root@test-200 ~]#rm a.txt
rm:remove regular empty file ‘a(chǎn).txt’?
刪除空的
6.6 [root@test-200 ~]# cp /tmp/a.txt /root/a.txt
cp:overwrite ‘/root/a.txt’?
確定覆蓋a.txt
6.7 [root@test-200 ~]# id www
id: www: no such user
www用戶不存在
6.8[test@test-200 /]$ cd /root
bash: cd:/root: Permission denied
權(quán)限不夠
6.9 [root@test-200 /tmp]# cp -q a.txt c.txt
cp: invalidoption -- 'q'
沒有q這個(gè)參數(shù)
6.10 [root@test-200 /home]# useradd test
useradd: user'test' already exists
test用戶存在