clear
Ctrl
+L
OR clear
clear the terminal screen
tab
click tab
to auto-complete the file/directory/command-name you’re typing
pwd
pwd
print work directory 目前路徑
cd
cd
change directory 改變路徑至。。。
.
current directory..
parent directory of current directory
cd ..
means back to the directory to the previous tree level
ls
ls
list the folders and files that are under the current directory
e.g. 輸入
ls
後的結果,舉例:
右邊配有/
斜槓代表是folder。
配有*
星號代表該檔案是machine code file(即是入面全是0和1的binary,可以讓電腦 execute的檔)。 例如, hello.c 是 source code file,入面是我們看得懂的英文字寫的程式,而要 execute 這個檔,首先要把 source code compile to machine code,那麼電腦才能看得懂來execute。而要把 source code file 轉成 machine code file 就要用make
。
ls -a
- lists all contents, including hidden files and directoriesls -l
- lists all contents of a directory in long formatls -t
- order files and directories by the time they were last modified.ls -alt
use -a -l- t together.
make
make
to build executable programs and libraries from source code
cp
cp
copy and paste file or directory
FIRST:
source file
; SECOND:destination directory
e.g.cp hi1/a.txt hello2/
: means copy thea.txt
file in hi1 folder and place it in thehello2
folder
e.g.cp hi1/a.txt hi1/b.txt hello2/
: copy multiple files into a directory. Here copy the fileshi1/a.txt
andhi1/b.txt
into thehello2/
directory.
rm
rm
remove files or directories (i.e. delete)
rm -f
force to remove (will not prompt a confirmation message before delete)rm -r
recursively remove entire directory and all of its child directories.rm -rf
recursively and forcibly remove entire directory
mv
mv
move/ rename
(1) Move file.
FIRST:source file
; SECOND:destination directory
e.g.mv superman.txt superhero/
(2) Rename.
FIRST:original name
; SECOND:name that going to be
e.g.mv batman.txt spiderman.txt
means rename all “batman.txt” to “spiderman.txt”
mkdir
mkdir
make directory (i.e. create a new folder)
touch
touch
create new file
可批量創建多個空白檔案,例如 hello_1.txt, hello_2.txt … hello_10.txt
bash
touch hello_{1...10}.txt