1. 程式人生 > >原版英文書籍《Linux命令列》閱讀記錄1 | 什麼是shell?

原版英文書籍《Linux命令列》閱讀記錄1 | 什麼是shell?

背景: 閱讀英文原作只為了更好地理解書中的精髓,當然也是為了更好地掌握書中的技巧。我們會堅持閱讀全書,並記錄書中的精髓。

1. 理解 Linux 的 “自由”

Many people speak of "freedom" with regard to Linux. Freedom is the power to decide what your computer does and the only way to have this freedom is to know what your computer is doing. Freedom is a computer that is without any secrets, one where everything can be known if you care enough to find it.

很多人一說到Linux, 就會說自由。但是你真的而理解這種自由嗎?這種自由是一種權力,能夠決定你的計算機幹什麼,獲取這種自由的唯一方式就是知道你的計算機在做什麼。自由就是你的計算機沒有任何㊙️,你可以從計算機那裡瞭解一切,只要你用心去尋找。

2. 什麼是 shell

We speak of the command line, we are really referring to the shell. The shell is a program that takes keyboard commands and passes them to the operating system to carry out.

一說起命令列,我們真正指的是 shell。shell 就是一個程式,把鍵盤的輸入傳遞給作業系統去執行。

3. 初次相遇 shell

第一次見到 shell,你只會看到一行提示符,形如:[[email protected] ~]$

This is called a shell prompt and it will appear whenever the shell is ready to accept input.

這叫做 shell 提示符, 無論何時當 shell 準備好接受輸入時,就會閒這樣的提示符。當然,出現的形式會根據不同的 Linux 發行版有所不同。但是大體上會包含 主機名

使用者名稱 當前目錄 和一個美元符號

?另外,如果提示符最後是 # 號,而不是 $,會表示這是一個具有 super root 許可權的終端。

3. 一些簡單入門的小命令

命令歷史:使用 ⬆️ 箭頭可以瀏覽以往的命令,以往的命令會重新出現在提示符後面。移動游標:使用 ⬅️ ➡️ 箭頭可以移動游標,來更好地編輯命令。時間:date 顯示系統當前時間和日期

[[email protected] ~]$ date
Sun Sep 30 10:02:00 CST 2018

日曆:cal 與上一個命令相關,預設顯示當前月份的日曆。

[[email protected] ~]$ cal
   September 2018
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

檢視磁碟剩餘空間:df

[[email protected] ~]$ df
Filesystem    512-blocks      Used Available Capacity iused               ifree %iused  Mounted on
/dev/disk1s1   489620264 166659552 315340480    35%  945005 9223372036853830802    0%   /
devfs                385       385         0   100%     666                   0  100%   /dev
/dev/disk1s4   489620264   6291496 315340480     2%       3 9223372036854775804    0%   /private/var/vm
map -hosts             0         0         0   100%       0                   0  100%   /net
map auto_home          0         0         0   100%       0                   0  100%   /home
/dev/disk2s1     5859376    378616   5480760     7%    2830          4294964449    0%   /Volumes/ACDSee
/dev/disk3s2      310480    283440     27040    92%     255          4294967024    0%   /Volumes/Charles Proxy v4.2.7
ximi:~ taoshilei$

結束終端會話:exit

Note: Don't be tempted to use Ctrl-c and Ctrl-v to perform copy and paste inside a terminal window. They don't work.

提示:不要在終端視窗使用 Ctrl-c 和Ctrl-v 來完成複製和貼上工作。這些不起作用。這兩個命令有別的含義,他們早於在微軟之前就已經定義了這兩個命令的含義,所以不是我們在windows下熟悉的複製貼上。