---
# System prepended metadata

title: Linux 讀書會 - 第 11 週 10/14/2014
tags: [' tossug', hackpad-import]

---

---
hackpadID: b6y4uC6HCCw
hackpadWorkspace: tossug
tags: hackpad-import, tossug
---
# Linux 讀書會 - 第 11 週 10/14/2014

總目錄 [edX Introduction to Linux](https://tossug.hackpad.com/dVX1LvoCcii)

## 課程筆記

**Chapter 14: Printing**

<undefined>*   **Common UNIX Printing System (CUPS)**</undefined>

Concentrating more on printing and less on how to print

*   Configuration Files
    *   /etc/cups/cupsd.conf -> system-wide settings
    *   /etc/cups/printers.conf -> printer-specific settings
*   Scheduler
    *   manage print jobs
    *   handle administrative commands
    *   allow user to query status (browser based interface)
    *   manage flow of data through all CUPS components
*   Job Files
*   Log Files
*   Filter
*   Printer Drivers
*   Backend

![](https://courses.edx.org/c4x/LinuxFoundationX/LFS101x/asset/LFS01_ch13_screen_05.jpg)

**CUPS** stores print requests as files under the `/var/spool/cups` directory.

These data files belong to what is commonly known as the **print queue**.

Log files are placed in `/var/log/cups` and are used by the scheduler to record activities that have taken place.

**Chapter 15: Bash Shell Scripting**

[Shell](https://en.wikipedia.org/wiki/Shell_(computing)) 提供使用者操作系統核心 (Core) 的介面，涵蓋範圍包括但不限於：

*   CLI
*   GUI

<undefined>*   **CLI**</undefined>

![](https://courses.edx.org/c4x/LinuxFoundationX/LFS101x/asset/LFS01_chapter14_screen_5.jpg)

*   ash: 輕量級的 shell，符合 POSIX 標準，許多 UNIX 系統的預設 shell。
*   Dash: 基於 ash，功能較完整，未完全相容 Bash。
*   Zsh: [](http://www.zsh.org/)http://www.zsh.org/
*   fish: [](http://fishshell.com/)[http://fishshell.com/](http://fishshell.com/)
*   Xikishell: [](http://xsh.org/)[http://xsh.org/](http://xsh.org/)
*   IPython: [](http://ipython.org/)[http://ipython.org/](http://ipython.org/)
*   Eshell: [](http://www.gnu.org/software/emacs/manual/html_node/eshell/)[http://www.gnu.org/software/emacs/manual/html_node/eshell/](http://www.gnu.org/software/emacs/manual/html_node/eshell/)
*   OpenSSH: [](http://www.openssh.com/)[http://www.openssh.com/](http://www.openssh.com/)
*   MS-DOS Shell
*   Command Prompt（命令提示字元）
*   Windows PowerShell

<undefined>*   **GUI**</undefined>

*   IPython Notebook
*   Windows Explorer
*   X Window System
*   Wayland
*   Mir

<undefined>*   **Section 1: Features and Capabilities**</undefined>

**shell script** 是一連串 shell 指令的集合，Linux 底下最常使用 Bash。

Linux 系統的 sh 通常指到 Bash，但也有可能指到 dash 或 ash，因此在撰寫 shell script 時，[應該在 script 第一行聲明](https://en.wikipedia.org/wiki/Shebang_(Unix) )。

<undefined>*   **Section 3: Constructs**</undefined>

*   doubled brackets [](http://mywiki.wooledge.org/BashFAQ/031)http://mywiki.wooledge.org/BashFAQ/031
    *   Not portable, only in Bash, Zsh and Korn shell
    *   Arguments need not be quoted while contianing whitespace
    *   Parentheses do not need to be escaped

由本章節主要探討 Bash Shell Scripting，實務上我們主要也會是寫 Bash，相容性的問題不必理會。

<undefined>*   **重點回顧**</undefined>

*   最基本的 Linux Base System 都會有 Bash。
    *   客製化或非 Linux 系統不在此限。
*   若您需要相容 ash，建議一開始就用 ash。
    *   ash 功能比 Bash 精簡很多，可以視為是 Bash 子集。
*   不建議直接使用 sh，請指定 shell 類型。
    *   每個系統的 sh 不一定是 Bash，可能指到別的 shell。
    *   即便語法可能相容，若沒測過，執行結果無法預期。
*   熟悉 Shell Scripting 需要多看多練習。
    *   參考別人的 shell script 就是一種入門捷徑。
*   Shell Script 可視為是一種字串取代的過程。
    *   function 回傳值只要呼叫 echo 即可。
*   Shell Script 可以 import / include。
    *   您可以把程式拆成許多函式庫和模組。
*   Defensive Programming 有助於減少錯誤。
    *   條件判斷可以轉成 function，搭配 `&&` 和 `||` 操作。

<undefined>*   **參考資料**</undefined>

Linux Standard Base (LSB) Referenced Specifications

[](http://refspecs.linuxfoundation.org/lsb.shtml)http://refspecs.linuxfoundation.org/lsb.shtml

Defensive BASH Programming

[](http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/)http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/

shUnit2

[](https://code.google.com/p/shunit2/)https://code.google.com/p/shunit2/

Bash Debugger

[](http://bashdb.sourceforge.net/)http://bashdb.sourceforge.net/

## 本週作業

*   Review Chapter 15: Bash Shell Scripting
*   Study Chapter 16: Advanced Bash Scripting

## 活動簽到

[Carl Su](/ep/profile/n5euV0AaWLn)

[Bruce Tsai](/ep/profile/oLLqeaQgDjg)

[steven huang](/ep/profile/sncZfUbLaeE)

[P Fisher](/ep/profile/oTOWRrYfPRk)

[Sam Lu](/ep/profile/zi86w39M6U6)

[violetson](/ep/profile/oJusv72f72w)
