avatar

目錄
Terminal Command Line / CMD / Linux 常用指令

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 directories
ls -l - lists all contents of a directory in long format
ls -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 the a.txt file in hi1 folder and place it in the hello2 folder
e.g. cp hi1/a.txt hi1/b.txt hello2/: copy multiple files into a directory. Here copy the files hi1/a.txt and hi1/b.txt into the hello2/ 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 -rfrecursively 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

References:

如果您喜歡我的文章,歡迎幫我在下面按5下讚!感謝您的鼓勵和支持!

文章作者: ouoholly
文章鏈接: https://ouoholly.github.io/post/cmd-terminal-command/
版權聲明: 本博客所有文章除特別聲明外,均採用 CC BY-NC-SA 4.0 許可協議。歡迎「部份引用」與介紹(如要全文轉貼請先留言詢問),轉載引用請註明來源 ouoholly 的倉庫,謝謝!

評論