現在的位置: 首頁 > 綜合 > 正文

王曉林老師Linux複習資料

2014年03月05日 ⁄ 綜合 ⁄ 共 3903字 ⁄ 字號 評論關閉
1. 利用ssh遠程登錄到cisd-ftp.swfc.edu.cn服務器.

$ ssh 12345678900@cisd-ftp.swfc.edu.cn

2. 在自己的home目錄下(/home/students/$USER/)建立一個新目錄exam-xxxxxxxxxxx (其中xxxxxxxxxxx為你的學號).

>> 在下一行的 ~$ 後面寫出你用的完整命令(本題5分):
>> ~$ mkdir exam-12345678900

3. 修改exam-xxxxxxxxxxx目錄的屬性, 使其為(rwx------), 即owner具有讀,寫,執行(rwx)權限, group和other不具備任何權限.

>> 在下一行的 ~$ 後面寫出你用的完整命令(本題5分):
>> ~$ chmod og-rwx exam-12345678900

4. 填空題(本題30分, 每空2分):
4a. 查看我正在哪個目錄下工作, 用命令_pwd_____.
4b. 查看我正在用哪個用戶名工作, 用命令_whoami_____.
4c. 隨便舉出3個查看文本文件內容的命令 _cat_____, _less_____, _more_____.
4d. 命令 ls -tl 中的 -tl 起什麼作用? ___長列表, 按時間排序_______________.
4e. 命令 cp -r src dst 中的 -r 起什麼作用? ____拷貝目錄中的所有內容______.
4f. 命令 ps 是用來____查看我當前的進程____________________.
4g. 將一個在前台(foreground)工作的進程推到後台(background), 要分兩步:
1. ______Ctrl-z________________________.
2. ______bg________________________.
4h. 命令 import 是用來 ___屏幕截圖__________________.
4i. 命令 gimp 是用來 _____圖象編輯__________________.
4j. 命令 info 是用來 _____查看命令的詳細說明__________________.
4k. 命令 convert 是用來 __轉換圖形文件格式__________________.
4l. 命令 pdflatex 是用來 _編譯LaTeX文件, 生成PDF文件_______________.

5. 進入exam-xxxxxxxxxxx目錄, 在此目錄下完成以下內容:

5a. 將/home/staff/wx672/exam/linux/exam.tgz拷貝到exam-xxxxxxxxxxx目錄中, 並打開壓縮包.
打開壓縮包後, 在你的exam-xxxxxxxxxxx目錄中會出現0,1,2,3,4,5,6,7,8,9等十個目錄.
在這十個目錄中, 又各有若干子目錄和文件.
其中有一個文件的內容里含有 I am here! 這句話.
請找到這個文件, 並在下一行的 >> 後面寫出它的絕對路徑. (本題10分)

>> 用下面的命令來搜索:
~$ grep -R 'I am here!' ~/exam-12345678900

5b. 將此文件中的所有xxxxxxxxxxx替換為你的學號. (本題5分)

為清晰起見, 我沒有全部替換, 只在此給出命令, 在vim中:

%s/xxxxxxxxxxx/12345678900/g

5c. 將此文件中的所有包含xxxxxxxxxxx(你的學號)的行, 輸出到exam-xxxxxxxxxxx目錄下的xxxxxxxxxxx.out文件.(本題5分)

$ grep 12345678900 exam-paper > 12345678900.out

5d. 編寫一個簡單script(名字叫my-cp.sh), 用它將xxxxxxxxxxx.out文件拷貝到0,1,2,3,4,5,6,7,8,9這十個目錄中.(本題15分)

=================================
#!/bin/bash
for i in 0 1 2 3 4 5 6 7 8 9; do cp 12345678900.out $i; done

或者:
#!/bin/bash
i=0

while [ i -lt 9 ]
do
cp 12345678900.out $i
i=`expr $i + 1`
done

還有很多方式, 不贅述了, 自己看書練習.
=================================

6. 在exam-xxxxxxxxxxx目錄下, 建立20個文件(文件名分別為f1, f2, f3, ..., f20).

=================================
for ((i=1; i <= 20; i++)); do touch f$i; done

還有很多方式, 不贅述了, 自己看書練習.
=================================

6a. 在這20個文件中, 各寫入一句話: (本題10分)
在文件f1中寫: this is f1.
在文件f2中寫: this is f2.
在文件f3中寫: this is f3.
...依此類推,
在文件f20中寫: this is f20.

=================================
for ((i=1; i<=20; i++))
do
cat this is f$i > f$i
done

還有很多方式, 不贅述了, 自己看書練習.
=================================

6b. 將這20個文件累加到一起, 生成一個新文件f21. (本題5分)

=================================
for ((i=1; i<=20; i++))
do
cat f$i >> f21
done
還有很多方式, 不贅述了, 自己看書練習.
=================================

6c. 將文件f21的屬性改為(rw-rw-r--). (本題5分)

$ chmod g+w f21

7. 用tar將exam-xxxxxxxxxxx目錄打成tgz壓縮包, 並將其拷貝到/home/staff/wx672/exam/linux/answers/目錄中.
(本題5分)

$ cd
~$ tar zcf exam-12345678900.tgz exam-12345678900
~$ cp exam-12345678900.tgz /home/staff/wx672/exam/linux/answers/

考試結束.

======================
這 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
么 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
多 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
的 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
東 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
西 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
要 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
替 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
換 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
, xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
真 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx
是 xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxx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