第三次考試題

第三次考試

1.1 闡述絕對(duì)路徑與相對(duì)路徑的區(qū)別
絕對(duì)路徑是從/開始的
是從當(dāng)前路徑開始的路徑

1.2 簡(jiǎn)述軟連接與硬連接的區(qū)別
軟連接:快捷方式,不同的inode指向同一個(gè)block,刪除軟連接對(duì)應(yīng)源文件無任何影響,刪除源文件,則軟連接失效.
硬鏈接:多個(gè)相同的inode指向同一個(gè)block,其實(shí)就是用來對(duì)文件做備份的.

1.3 簡(jiǎn)述命令執(zhí)行的流程
判斷命令是否通過絕對(duì)路徑執(zhí)行
判斷命令是否存在alias別名
判斷用戶輸入的是內(nèi)置命令還是外置命令
bash 內(nèi)部命令直接執(zhí)行,外部命令檢測(cè)是否存在緩存
*通過
PATH變量查找命令,有執(zhí)行,無報(bào)錯(cuò)command not found絕對(duì)路徑--->alias--->hash緩沖---->------PATH變量查找命令--->有執(zhí)行--->沒有command not found

1.4 寫出查詢 file.txt 以 abc 結(jié)尾的行
grep ‘a(chǎn)bc$' 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 Davvid -GA
useradd Peter -GA|

1.6.2 建立目錄 yf_a,該目錄里面的文件只能由研發(fā)部人員讀取、增加、刪除、修改以及執(zhí)行,其他用戶不能對(duì)該目錄進(jìn)行任何操作
mkdir yf_a
chown A yf_a
chomd 770yf_a

1.6.3 建立目錄 yf_b,該目錄里面的文件只有研發(fā)部的 David 擁有所有權(quán)限,研發(fā)部的其他人只有查看權(quán)限,其他部門不能進(jìn)行任何操作
mkdir yf_b
chown David.A yf_a
chmod 740 yf_b,

1.7 有一用戶 oldboy,及用戶組 oldboy,在 code目錄下創(chuàng)建的所有文件自動(dòng)歸屬于 oldboy 組
chmod g+s code

1.8 有兩個(gè)用戶組 python 及 Linux,python 組可以修改讀取/hom/python/目錄下所有內(nèi)容,但不能讓 Linux 組讀??;Linux 組可以修改讀取/home/linux/目錄下所有文件,但不能組讀取。給出配置命令。
hmown .python /tmp/python
chmod 770 /tmp/python
chown .Linux /tmp/Linux
chmod 770 /tmp/Linux

二、find 相關(guān)(每題 3 分)

2.1 找出/tmp 目錄下,屬主不是 root 的文件
ind /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 / -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 {print2}')_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

4.6 卸載 sl 這個(gè)命令
rpm -r 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 rsync

4.9 yum 安裝多個(gè)軟件,例如 sl、lsof、nettools、nmap 等
yum install sl lsof net-tools nmp -y

4.10 查看你的服務(wù)器中有哪些可用的 yum 源倉(cāng)庫(kù)。
yum repolist all

五、進(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/ -name '*.conf' -mtime -7 -exec 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
未找到命令

6.3 [root@test-200 ~]# mkdir a
mkdir: cannot create directory ‘a(chǎn)’: File exists
無法創(chuàng)建目錄a 因?yàn)槲募嬖?/p>

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’?
刪除常規(guī)的空文件“a.txt”

6.6 [root@test-200 ~]# cp /tmp/a.txt /root/a.txt
cp: overwrite ‘/root/a.txt’?
是否覆蓋/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
沒有權(quán)限

6.9 [root@test-200 /tmp]# cp -q a.txt c.txt
cp: invalid option -- 'q'
沒有這個(gè)選項(xiàng)

6.10 [root@test-200 /home]# useradd test
useradd: user 'test' already exists
用戶已存在

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • tar命令的介紹 saves many files together into a single tape or ...
    溫東閱讀 1,252評(píng)論 0 0
  • Linux啟動(dòng)過程 1.開機(jī)自檢BIOS 2.MBR引導(dǎo) 3.GRUB菜單 4.加載內(nèi)核 5.運(yùn)行init進(jìn)程 6...
    康樂_SH閱讀 544評(píng)論 0 0
  • 基本命令-2 壓縮和歸檔 打包: 即歸檔,類似于旅游之前收拾行李 壓縮: 為了減少占用的磁盤空間,可以做備...
    崔千易閱讀 1,055評(píng)論 0 0
  • 一、基礎(chǔ) 1.1 闡述絕對(duì)路徑與相對(duì)路徑的區(qū)別 相對(duì)路徑:從當(dāng)前目錄開始的就是相對(duì)路徑 絕對(duì)路徑:從根開始的路徑就...
    閆夢(mèng)超閱讀 456評(píng)論 1 0
  • | Day11 || 作者:方維超 歸檔:課后筆記 時(shí)間:2019/3/14 || 快捷鍵: Ctrl + 1 標(biāo)...
    Ffvc閱讀 432評(píng)論 0 0

友情鏈接更多精彩內(nèi)容