2017年3月23日 星期四

0317linux上課心得

今天仍然到5A進行linux的指令操作。而上課一開始,老師便教導我們,有哪些命令類型並如何觀看,根據The Linux Command Line,命令可分為四種類型,分別為:

  1. 可執行程式。An executable program like all those files we saw in /usr/bin. Within this category,programs can be compiled binaries such as programs written in C and C++, or programs written inscripting languages such as the shell, perl, python, ruby, etc是一個可執行程式,就像我們所看到的位於目錄/usr/bin 中的檔一樣。 屬於這一類的程式,可以編譯成二進位檔案,諸如用 C  C++語言寫成的程式也可以是由指令碼語言寫成的程式,比如說 shellperlpythonruby,等等。
  2.  內建於 shell 的命令。A command built into the shell itself. bash supports a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.是一個內建於 shell 自身的命令。bash 支持若干命令,內部叫做 shell 內部命令 (builtins)。例如,cd 命令,就是一個 shell 內部命令。
  3. shell 的函數。A shell function. These are miniature shell scripts incorporated into the environment. We will cover configuring the environment and writing shell functions in later chapters, but for now, just be aware that they exist. 是一個 shell 函數。這些是小規模的 shell 腳本,它們混合到環境變數中。 在後續的章節裡,我們將討論配置環境變數以及書寫 shell 函數。但是現在, 僅僅意識到它們的存在就可以了。
  4. 別名。An alias. Commands that we can define ourselves, built from other commands.是一個命令別名。我們可以定義自己的命令,建立在其它命令之上。
將目前所學之指令前面加上"type",即可觀看其指令之類型。以下依序列出目前所學之指令並介紹其屬於哪種指令類型,共十六個:
(1)      user@debian404040339:~$ type date
date is /bin/date為可執行程式。
(2)      user@debian404040339:~$ type cal
cal is /usr/bin/cal為可執行程式。
(3)      user@debian404040339:~$ type df
df is /bin/df為可執行程式。
(4)      user@debian404040339:~$ type free
free is /usr/bin/free為可執行程式。
(5)      user@debian404040339:~$ type exit
exit is a shell builtin內建於 shell 的命令。
(6)      user@debian404040339:~$ type pwd
pwd is a shell builtin內建於 shell 的命令。
(7)      user@debian404040339:~$ type cd
cd is a shell builtin內建於 shell 的命令。
(8)      user@debian404040339:~$ type ls
ls is aliased to `ls --color=auto' 最先使用之aliase。(為別名)
(9)      user@debian404040339:~$ type cd -
cd is a shell builtin內建於 shell 的命令。
bash: type: -:沒有找到
(10) user@debian404040339:~$ type file
file is /usr/bin/file為可執行程式。
(11) user@debian404040339:~$ type less
less is /usr/bin/less為可執行程式。
(12) user@debian404040339:~$ type cp
cp is /bin/cp為可執行程式。
(13) user@debian404040339:~$ type mv
mv is /bin/mv為可執行程式。
(14) user@debian404040339:~$ type mkdir
mkdir is /bin/mkdir為可執行程式。
(15) user@debian404040339:~$ type rm
rm is /bin/rm為可執行程式。
(16) user@debian404040339:~$ type ln
ln is /bin/ln為可執行程式。

11個可執行程式,4個內建於 shell 的命令,0個為shell 的函數,1個別名。
以下為指令在終端機的呈現:




參考資料:

沒有留言:

張貼留言