
開工囉!
179
操作檔案與目錄
請 用 mkdir(
make directory
) 指 令 來 建
立一個目錄,後面加上您想要為這個目
錄取的名稱。這裡要介紹兩個指令;第
一個要確保在執行後續所有練習題之前,
要先回到您的家目錄(如果單純只輸入
cd,就會直接回到家目錄):
pi@raspberrypi ~ $ cd
pi@raspberrypi ~ $ mkdir test
現在進入這個指令,並用 touch 指令建立
一個空白檔案;接著用 ls 指令檢查系統
是否確實建立了這個檔案:
pi@raspberrypi~ $ cd test
pi@raspberrypi~/test $ touch hello.txt
pi@raspberrypi~/test $ ls
hello.txt
pi@raspberrypi~/test $ ls -l
total 0
-rw-r--r-- 1 pi pi 0 Feb 15 19:42 hello.
txt
cp 指令,代表
copy
,可用來複製檔案,
後面加上您所要複製的檔案名稱以及複
製的 目 的 地。 請 用 以 下 指 令 將
hello.txt
檔案複製到
home/pi
目錄中:
pi@raspberrypi ~/test $ cp hello.txt /
home/pi
由於 home 目錄比現在的目錄高一層,您
也可以這樣寫:
pi@raspberrypi ~/test $ cp hello.txt ..
由於 ~ 是您的家目錄捷徑,上述指令也
可以這樣寫:
pi@raspberrypi