王詠平
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `1121` `lsa` `ncnu` # FHS - Book mode: https://hackmd.io/@ncnu-opensource/book [TOC] --- ## Linux 簡介 - 作者: Linus Torvalds(林納斯·托瓦茲) - 芬蘭人 - 1991 年,林納斯·托瓦茲在赫爾辛基大學上學時,想嘗試在 PC 上面做一個 Unix 系統。 - Linux Foundation(Linux基金會) - 一家非營利性技術協會,致力於促進,保護和推進 Linux 和協同開發 - 自由和開放原始碼的 **類 UNIX(UNIX-like)** 作業系統 - 從 UNIX 衍生出的系統 - 只有符合單一 UNIX 規範的系統才稱為 **UNIX** 系統 - UNIX 因為是一個商標,所以不能亂用 - UNIX 一開始是大型主機,所以在 UNIX 相關的系統中,不會分槽 - 世界觀是不同的:大型主機是一個系統 - Linux 標準規範 - 由 Linux Foundation 制定的規範 - 使 Linux 作業系統符合檔案系統架構標準(FHS)的規範及標準。 ## 硬碟 ### SSD(固態硬碟) - 優點:沒有seektime(讀取時間),存取速度比較快、體積小 - 缺點:快滿的時候會掉速、比較貴 ### HDD(傳統硬碟) - 優點:單位容量大、價格便宜 - 缺點:會轉、速度慢 ## FileSystem ### Ext4 - 可關閉日誌功能:檔案損毀可接受,但效能要最佳化。 - 磁碟容量最大可以支援到 1 EB(1 EB=1024PB, 1 PB=1024TB),單一檔案最大可以支援到 16 TB,單一目錄最多可以存放 64,000 個子目錄。 - 允許對一檔案預先保留磁碟空間。目前大多數檔案系統作到這點的方式就是直接產生一個填滿0的空間。 - fallocate - 提高檔案下次寫入的速度 ### swap(重點) SWAP 當實體記憶體 (RAM)用完時才會使用到,假如系統需要更多的記憶體資源,而實體記憶體已經用完,記憶體上不活動的頁面將會被移到swap 空間。 雖然 swap 空間可以幫助系統增加一小部份容量的 RAM,不過不能將它當作更多記憶體的替代品。Swap 空間是位於硬碟上,它的存取比起實體記憶體慢了很多。 swap空間建議是記憶體的兩倍,但也要依自己的使用習慣做決定。 :::info ### ZFS - **優點** - 可擴展性 - zfs 可在單個存儲池中存儲多個檔案系統,並隨著需要擴展存儲池的大小。 - 資料完整性 - zfs 使用 checksum 來驗證資料的完整性,並可在發生資料損壞時進行修復。 - 資料壓縮 - zfs 可壓縮資料以節省空間。 - 快照 - zfs 可建立快照,以便在發生資料損壞時還原到以前的狀態。 - 鏡像 - zfs 可鏡像檔案系統,以確保資料的安全性。 - RAID - zfs 可提供 RAID 保護,以提高資料可靠性。 - **缺點** - 要求配置高 - zfs 1 TB 需要 1 GB 的 RAM - 兼容性 - zfs 並非所有操作系統都支持。 ### Btrfs - 可擴展性 - Btrfs 可在單個存儲池中存儲多個檔案系統,並隨著需要擴展存儲池的大小。 - 容錯性 - Btrfs 使用 checksum 和校驗和樹來驗證資料的完整性,並可在發生資料損壞時進行修復。 - 可修復性 - Btrfs 可修復邏輯錯誤,例如檔案系統碎片和壞塊。 - 快照 - Btrfs 可建立快照,以便在發生資料損壞時還原到以前的狀態。 - 子卷 - Btrfs 可將檔案系統分割為子卷,以便更好地管理資料。 - 壓縮 - Btrfs 可壓縮資料以節省空間。 - RAID - Btrfs 可提供 RAID 保護,以提高資料可靠性。 #### Btrfs 的問題 - 相對 ZFS 來說,較容易炸裂(相對來說) ::: :::info ### exFAT 歷史悠久的檔案系統, 近年常見於需要跨平台儲存裝置 #### 優點 - 兼容性好 #### 缺點 - 沒有 Log,容易資料損壞 - 只適合用在有移動需求的設備 - USB Drive ::: ## 分區查詢指令 - `lsblk` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156892807760449616/CleanShot_2023-09-28_at_17.58.412x.png?ex=65169fe3&is=65154e63&hm=edf8ffc6a90d3795dc460abbdac22a20337b73ecfea93270a308893ebb88fd38&) - `sudo fdisk -l` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156892651413573642/CleanShot_2023-09-28_at_17.58.112x.png?ex=65169fbe&is=65154e3e&hm=0ff0c02dd1e2e8e2920596fcd1ad724bd08666badf37cb86609a1dcb0cbcac64&) :::info - `sudo cfdisk` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156893553843261470/CleanShot_2023-09-28_at_18.01.502x.png?ex=6516a095&is=65154f15&hm=01e2416304d0d7a3d072f1ba0703285d67b0899afcb18be64607b8f74af80636&) ::: ## FHS - FHS全名:Filesystem Hierarchy Standard(檔案系統階層標準) ### FHS架構 ![](https://hackmd.io/_uploads/Hyudg1Qga.png) `/cd` (change directory)前往特定目錄 `cd ..` 返回上一層 `pwd` (Present Working Directory)查看自己在哪一層 `ls` (list)是列出目錄底下有什麼東西 `ls -a` 可顯示隱藏檔案 `ls -al` 顯示的檔案名字綠色為可執行 (目錄裡前面-號有意義但來不及寫) `home` 顯示使用者的家目錄 `sudo` 用來取得root權限(會影響到系統,用之前一定要知道後面的指令在做甚麼,不要亂用) `sudo adduser` 創建使用者 `cat` 查看文本內容 `mkdir` (make directory)建立目錄 `ifconfig` 查看網路界面卡 > 現在會比較推薦使用 `ip addr` 來查看網路界面卡 > 可以使用環境變數 `LS_COLORS` 自定義不同類型的文件和目錄在 `ls` 命令輸出中所顯示的顏色,`LS_COLORS` 設定範例如下: > > `export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31'` > di=34:目錄 (directory) 顯示為藍色 (ANSI 顏色碼 34) > ln=35:符號連結 (symbolic link) 顯示為紫色 (ANSI 顏色碼 35) > so=32:socket 顯示為綠色 (ANSI 顏色碼 32) > pi=33:FIFO 管道 (pipe) 顯示為黃色 (ANSI 顏色碼 33) > ex=31:可執行文件 (executable) 顯示為紅色 (ANSI 顏色碼 31) #### 目錄 bin - /bin:binary - [bin 裡的函示庫](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s04.html) ###### 常用的 App - `sudo apt install net-tools` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156919900409958420/CleanShot_2023-09-28_at_19.46.262x.png?ex=6516b91e&is=6515679e&hm=7a14cdb687d884849452f6474fb2a2bb62a3722c50065fe4ef7a7a1e91f87e91&) :::info - `sudo apt install neofetch` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156919718062600223/CleanShot_2023-09-28_at_19.45.292x.png?ex=6516b8f3&is=65156773&hm=0da9fd849c7cfb6e6032f17ea3e0946f4ed9db639ec257b3d3baa7cf58de0b67&) - `sudo apt install bashtop` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156920739434340403/CleanShot_2023-09-28_at_19.49.442x.png?ex=6516b9e6&is=65156866&hm=ce13d27f2218d6d86be4a83a62d32574657b23b1103eda0182fa411b2e255d45&) - `sudo apt install speedtest-cli` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156920967176654938/CleanShot_2023-09-28_at_19.50.392x.png?ex=6516ba1d&is=6515689d&hm=a801b01a6fccc81a35b70f74df97522ee16fba4b854aa10ace53d2299bc4c7f2&) ::: #### Vim - `sudo apt install vim` ![](https://cdn.discordapp.com/attachments/1156841091904065597/1156921641373274132/CleanShot_2023-09-28_at_19.53.212x.png?ex=6516babd&is=6515693d&hm=08edcc42dbe1ace5ce406c33380f9ccb71f80039cb87727daec1d0a01cc8b7da&) :::info - 22.04LTS 可能出現 ``vim common`` 太新, 導致裝不了 ``vim``. - 先把 ``vim common`` 卸載掉, 再安裝 ``vim``. ::: ##### Vim 基礎指令 - 存檔 `:w` - 離開 `:q` - 編輯模式 `i` - 選取模式 `v` - 保存並離開 `:wq` - 顯示行數 `:set relativenumber` - 上一步 `U` - 剪下 `DD` - 移動到最上面 `gg` - 移動到最下面 `Shift + G` --- ![](https://hackmd.io/_uploads/H1UpYy7eT.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully