https://hackmd.io/@IMOK/Lab10
講師: 賴昱有
20 世紀 70 年代由 AT&T 的貝爾實驗室開發多使用者、多任務的作業系統
模仿了 Unix 的設計與概念的衍生系統其中 BSD 系列與 MacOS 較為知名
GNU's Not Unix!
推動自由、開源軟體的組織
最初的目標是建立一個完整的作業系統替代Unix
其提供工具包含GCC、Bash、glibc等
原使用GNU Hurd後使用Linux kernel作為核心
如 Debian、Ubuntu、Red Hat皆為GNU/Linux系統
Terminal or Console為用戶與主機進行互動的硬體裝置
如今多數情況下,通常指的是 CMD(命令提示字元)等虛擬介面。
使用者與作業系統之間的接口
將使用者指令解析後,與作業系統內核(Kernel)進行溝通
Bourne Shell(sh):最早期的 SHELL,由 UNIX 開發。
Bash(Bourne Again Shell):基於 Bourne Shell,加入許多新功能。
C Shell(csh):以 C 語言語法為基礎,適合熟悉 C 語言的使用者。
Korn Shell(ksh):結合 Bourne Shell 和 C Shell 的優點,適用於高效能腳本需求。
Z Shell(zsh):功能非常強大,兼容 Bash,但在腳本撰寫、介面美化及插件支援方面表現更佳。
Windows powershell : 內建於Windows系統,僅限於 Windows 作業系統使用。
是一種遠端連線的協定
不過是文字介面的
使用非對稱式加密 相比 telnet 更安全
用法 : ssh {user}@{host}
e.g. ssh b0135XXXX@linux.aclab.cool
or 使用 GUI (Bitvise SSh Client)
基於 SSH 的檔案傳輸協議,提供類似於 FTP 的功能,但所有通信都經過加密。
提供了文件操作的完整功能,如檔案上傳、下載、刪除、檔案權限修改等。)
基於 SSH 的檔案傳輸工具,用於快速、安全地傳輸檔案。
它的功能比 SFTP 簡單,主要專注於檔案的上傳和下載。)
列出檔案 ls -l
- rwx r- - r- -
permission | count | description |
---|---|---|
r | 4 | 讀取 |
w | 2 | 輸入 |
x | 1 | 執行 |
permission | count | description |
---|---|---|
r | 4 | 讀取 |
w | 2 | 輸入 |
x | 1 | 執行 |
permission | add up |
---|---|
r w x | 4+2+1=7 |
r w - | 4+2=6 |
r - x | 4+1=5 |
- - x | 1 |
chmod 666 example.txt
如果不知道指令怎麼用 請參考
command –help
man command
command | usage | description |
---|---|---|
chsh | chsh /bin/tcsh | 修改預設登入 shell |
passwd | passwd | 修改密碼 |
chmod | chmod 664 file | 修改檔案權限 |
ls | ls -l | 列出當前目錄下的檔案 |
cd | cd directory | 進入資料夾 |
pwd | pwd | 顯示目前的目錄位置 |
echo | echo "hello world" | 輸出文字 |
cat | cat file | 檢視檔案內容 |
command | usage | description |
---|---|---|
head | head -n 10 file | 檢視檔案前10行 |
tail | tail -n 10 file | 檢視檔案最後10行 |
grep | grep "apple" example.txt | 擷取有關鍵字的那一行 |
cp | cp file file_copy | 複製檔案 |
mv | mv file file_moved | 移動、重新命名檔案 |
mkdir | mkdir directory | 創建資料夾 |
touch | touch file | 創建檔案 |
vim | vim file | 使用 vim 編輯檔案 |
command | usage | description |
---|---|---|
chsh | chsh /bin/tcsh | 修改預設登入 shell |
ypchsh | ypchsh /bin/tcsh | 在 NIS 機器上修改預設登入 shell |
passwd | passwd | 修改密碼 |
yppasswd | yppasswd | 在 NIS 機器上修改密碼 |
修改預設登入 shell
e.g.chsh /bin/tcsh
修改密碼
e.g. passwd
修改檔案權限
e.g. chmod 777 file
列出目錄中的檔案與目錄列表
常用參數 -l -h -a
e.g. ls -alh
進入資料夾
e.g. cd Documents
顯示目前的目錄位置
輸出文字
e.g. echo "Hello World!!!"
輸入檔案用法:
e.g. echo "Hello World!!!" > file
叫貓貓去看一下檔案
檢視檔案內容
e.g. cat file
檢視檔案前x行
常用參數 -n
e.g. head -n 10 file
檢視檔案最後x行
常用參數 -n
e.g. tail -n 10 file
g/re/p(globally search a regular expression and print)
e.g. grep "apple" example.txt
grep -i "apple" example.txt for case-insensitive
複製
e.g. cp hello hello-copy
移動、更名
e.g. mv hello ../hello
創建資料夾
e.g. mkdir my-dir
文字介面編輯器
按 ESC 回到 normal mode
在 normal mode 打冒號可以輸入指令
Command | Description |
---|---|
:w | 儲存 |
:wq | 儲存並退出 |
:q! | 不儲存退出 |
vim 是個很強大的編輯器
在 normal mode 可以用的指令還有連技超多
如果想了解的可以看看 這個Vim
推薦要學 只能用文字介面的時候非常好用
另一個文字介面編輯器
joe filename.txt
operation | description |
---|---|
Ctrl+K,H | show help |
Ctrl+K,F | search text |
Ctrl+K,L | go to line |
Ctrl+K,S | save file |
Ctrl+K,X | save file and exit editor |
Ctrl+Y | delete a line |
作業做完請上傳到 http://140.121.197.13/tutorial
並且注意上傳時間限制、檔名、其他規範
上課時提前做完可以直接給助教 demo 登記
就不需要上傳 demo 過的部分
Change the permission of the directory www to drwxr-xr-x, and explain what does this mean.
From the previous exercises, upload your personal web page to the www directory. Use http://linux.aclab.cool/~b0135XXXX/ to view the page.
Copy the file /proc/cpuinfo to your directory, and rename the file to CPU (case sensitive).
Dump (show) the content of the file CPU and isolate
(using Linux commands) the CPU model.