老師
Can you also check out my answers?
Thank you. ^^
1)請列舉說明 shell 上常用的 Standard I/O (FD, Name, Device, Redrection):
說明:
FD Name Device Redirection
0 stdin keyboard
1 stdout monitor [1]> file
2 stderr monitor 2> file
2) 請問,要想將 STDOUT 與 STDERR 都存到同一份檔去(原內容必須保留), 請列出一個錯誤的寫法,及兩個正確寫法:
錯誤寫法: ls . /xxx > file 2> file
正確寫法 1: ls . /xxx >> file 2>&1
正確寫法 2: ls . /xxx 2>> file >&2
3) 請簡單說說 /dev/null 的作用是甚麼?
說明: 空設備, 可將output或error其中一者或兩者, 輸出到/dev/null, 就不會出現在螢幕, 也不會存起來
若在一個 command 中同時產生 STDOUT 與 STDERR , 請問要如何讓螢幕只送出 STDERR ?
命令語法: [1]> /dev/null
要是反過來,只留下 STDOUT 呢?
命令語法: 2> /dev/null
或是,要將兩者都隱藏掉呢?
命令語法: &> /dev/null
4) 請問有何方法不影響命令原本輸出到螢幕結果的情況下,
同時將結果(含 stdout 與 stderr)增加到另一指定的 log file 去?(log file 原有內容必須保留)
方法: tee -a log file
5) 請解說如下兩個命令的結果為何不同:
ls *.txt | cat
ls *.txt | xargs cat
說明: (1)會把cmd1的output作為cat的input, 而cat就會把結果直接輸出到螢幕, 不做任何改變
(2)會把 cmd1的output交給cat, 作為cat的argument, 而執行命令
6) 列舉一些在 Linux 常見的 disk 類型, 及其路逕.
說明:
hard disk: had
floppy disk: fd0
CD/DVD: hdc
7) 請問第二個 IDE controler 的第一個 channel 的 slave 位置, 其路逕是甚麼?
說明: hdf
8 ) 能否說說 disk 與 partition 的關係? partition 是以啥單位來區分界限的呢?
說明: disk, 是根據cylinder來切分成多個partitions
9) 請說明 primary, extened, logical 這三種 partition 類型的差別與關係, 及他們的路逕.
說明: primary: 主要分割區, 最多可切4個 (編號1~4) hda{1-4}
extended: 延伸分割區, 從單一個primary轉成的 (編號2~4) had{2-4}
logical: 一定要從extended中切割 (編號必從5開始) hda5…….
10) 請列舉 fdisk 命令常用的命令及其作用.
說明: m: for help
p: printing partition table
n: create a new partition
d: delete a partition
l : list file system ID
t : change file system ID
a : boot flag (set & unset )
q : quit without saving
w : save and exit
11) 請說明 partition 與 format 的關係?並列舉 PC 上常見的檔案系統類型, 及其相關命令:
說明:要在partition上作format(建構一個檔案系統),才可進一步讀取資料
Linux(83)------ext2, ext3, xfs, reiserfs
Linux swap (82)
microsoft: msdos, vfat, ntfs
12) 請列舉常見的 block 類型. 請問 block 與 inode 的作用是甚麼?
說明:
1. super block
2. inode block
3. data block
4. indirect block
block:存放檔案內容
inode:存放檔案的描述與相關資料(descriptions & information)
13) 請問在格式 ext2/ext3 檔案系統時, 有哪些參數可用來修改 inode 與 block 數量的? 並說明取值大小之間的差別.
說明: mkfs
-b <n> partition (切割data block的大小)
-i <n> (多少k的data出現1個inode)
-N <n> (inode的絕對數目,但仍為大約值)
-T <type> news (1 inode/4kb)
largefile (1 inode/mega)
largefile4 (1 inode/4 mega)
14) 在 Linux 上,所有存取項目都以檔案形式出現,請問 file 與 directory 的差別在哪裡?
請以實際的操作結果, 簡要說說在檔案系統上找到 /etc/hosts 的過程:
(提示:嘗試說明 inode 與block 的功能)
說明:
super block-> top dir_inode-> top dir_block-> sub dir_inode-> sub dir_data block
super block-> file_inode-> file_data block
15) 您問您會用哪個指令來列示目錄的內容?
命令:ls
16) 請問 partition 一經切割完畢就能使用嗎?(能/不能) 不能
要是不能,下一動作是甚麼? format格式化
動作: mkfs
若用 mkfs 指令將 /dev/hda10 給格式為 ext3 ,且同時檢測壞的區塊,
請問您的完整指令如何下?
命令(可有多個答案): # mkfs -t ext3 -c /dev/hda10
17) 假設 /dev/hdb8 的 id 是 82 ,請問你如何將之啟用為 Linux 的 swap ?
步驟:
# mkswap /dea/hdb8
# swapon /dev/hdb8
18) 若我要想使用已經格式為 ext3 的 hda10 , 且要掛在 /mnt/test 目錄上,不過該目錄尚不存在,
請問指令要如何下?
步驟:
# madir /mnt/test (先新建這個目錄,所以也可確定為空目錄)
# mount /dev/hda10 /mnt/test
若你不小心將多個 device 掛在同一個 mount point 上, 將會有何結果?
說明:會以最後那個device為主
19) 若要將上一題掛載好目錄給卸載掉,可用的方法有兩個,
你知道哪兩個嗎?
方法一:# umount /dev/hda10
方法二:# umount /mnt/test
請問,若要成功完成卸載,條件是甚麼?
條件:mount point下,不能有行程(process)進行
若你想查出某一目錄或檔案當前被甚麼程式在使用, 你可用哪個工具?
工具名稱: fuser
並請說說 fuser 的 -k 參數的用途:
用途:把正在進行中的process殺掉(kill)
20) 能否說明一下 hard link 跟 soft link 是甚麼?有何不同?
說明: hard link是透過指令,建構出一個名字,指到同一個inode
而 soft link是透過一個名字,指到另一個inode,來重新讀取file_name
請問建立 hard link 跟 soft link 的命令跟參數是甚麼?
hard link : ln -d
soft link : ln -s
請問你如何得知檔案的 link count ?
方法:
那 link count 對 file content 有何影響?
影響: 當刪除一份檔案時,link count會減少
若link count仍>0 --> file content仍存在
若link count = 0 --> 則inode刪除, file content也刪除