NCNU-OpenSource
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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: `lsa` `ncnu` # Week 02 (2023/03/02) - Book mode: https://hackmd.io/@ncnu-opensource/book [TOC] --- ## 硬碟 - 硬碟=記憶體 - 單位為 sector(磁頭) ### 傳統硬碟vs固態硬碟 - HDD - cheap - more noise - SSD - 貴 - 容量小 - 損毀後不容易復原 - 噪音小 ## FHS - `/boot` 開機相關指令 - `/dev` 硬體設備相關設定 - `/etc` 系統設定檔 > 一般使用者可以查看,但只有超級使用者可修改 - `passwd` - `shadow` 只有super user 可觀看 ![](https://i.imgur.com/hDjA0L1.png) > 使用者名稱/使用者上次修改日期/密碼多久後要做變更(`99999`:無須固定時間做更改) - `group` > ![](https://i.imgur.com/xURehVH.png) > 群組名稱(不可重複)/口令/群組id - `/lib` 系統函式庫 - `/media` 系統會自動將裝置掛載在這 - `/sbin` 超級使用者可以做的指令 - `/srv` 啟動網路服務需要使用的資料 - `/tmp` 暫時存放資料的地方 > 過一段時間系統就會自動清除 > :star: 建議不要把檔案存放在這 - `/usr` 使用者資訊 - `/usr/lib` & `/lib` 已經合併使用 - `/usr/local` 存在放在這就不會衝突? - `/usr/share`:唯讀檔案,大部份是文字檔,系統開發者所開發出來的檔案不需要使用 - `/var`: 開機後占用硬碟的容量會不斷增加 - `/var/cache` 暫存檔 > 如果要重新下載應用程式,可以直接從暫存檔中找到,不須重新下載,節省下載時間 - `/var/lib` :程式在運作的過程中需要用到的資料 - `/var/lock`:一個檔案會被不同裝置使用,有人使用時要先lock,等第一個使用者使用完成後,才會開放,避免發生錯誤 - `/var/log`: 存放登入的資料,登入系統時的紀錄 - wtmp: 使用者登入的相關訊息 - btmp: 紀錄登入時錯誤的訊息 - `/var/mail`: 個人郵件信箱的相關目錄 - `/var/spool`: 存放需要排隊存取的資料 - `/proc` 紀錄系統中處理的相關資訊 > 為虛擬檔案系統,不佔硬體空間 >此目錄底下的檔案是可讀可寫的 - `/proc/cpuinfo`: 紀錄 cpu 資訊以及狀況 - `lost+found` 紀錄系統檔案被遺忘的資訊 - `sys`:關於設備的資訊 - 虛擬檔案系統,不佔系統空間 - 檔案可讀可寫 - `/sys/device` : 系統設備,按照系統類型做管理 ## 基本指令 - cd: 切換目錄 - `.` 目前的目錄 - `..` 回到上一個目錄 - `~`or 空格 : 回到家目錄 - `/` 回到根目錄 - ls: 列出目前目錄下的檔案 - `-a` 印出隱藏檔案 - `-l` 用清單的方式印出 - `al`: ![](https://i.imgur.com/fknGhQG.png) > `d`: directory , `-` : 檔案 > `r` 可讀 > `w` 可寫 - `clear` 清空 terminel - `touch` 建立檔案 (白色) - `mkdir` 建立資料夾 (藍色) - `rmdir` 刪除資料夾 >只限於目錄是空的狀態下 - `rm` 刪除 - `-r` 刪除目錄底下的所有檔案 - `-f` 強制刪除 > `f`: 強制 > `r`: recursive遞迴,將下層檔案一併都刪掉 - `echo <content>` 在terminal 上顯示出 echo 的 `<content>` - `echo <content> > <file>` 建立 file 寫入 content - `echo <content> >> <file>` 把 content 覆寫進 file - mv `<file>` `<資料夾>`: 把file 移到 資料夾 裡面 - `cp <source> <destination>` 複製 source 到 destination - `-a` 整份檔案權限&內容完整複製到目的地 - grep `關鍵字`: 找在這個目錄下有這個關鍵字的內容 > ex: `ls | grep 3` 找到的關鍵字會用紅色標示 > ![](https://i.imgur.com/oNsdgF9.png) > `|`:可以將前面指令的輸出當作後面指令的輸入 - `ln` - `-s` softlink - 幫你記住檔案的位置,所以源檔案被刪除,soft link 就會找不到此檔案的內容 ![](https://i.imgur.com/5H8O0Wl.png) > ex: bbbb 指到 aaaa - 可以指到不存在的檔案 ![](https://i.imgur.com/koRoJC9.png) - soft link 是額外檔案,所以 ID 不同 - hardlink - 幫你記住檔案內容 - 如果指到不存在的檔案會出錯 - 代表有幾個 hardlink 指向此檔案 ![](https://i.imgur.com/JPLoroT.png) - 只能指到同一個檔案目錄下 >若新增一個資料夾 則會有兩個hardlink 指到此資料夾 >原因為有 `.` 與 `..` 此兩個檔案 >![](https://i.imgur.com/kdYJZtO.png) - hard link 因為是指到同一個檔案,所以 ID 是一樣的 - `chmod` 更改權限 > ![](https://i.imgur.com/pJtMwLw.png) - `whoami` : 輸出自己當前的用戶名 - `exit` : 登出當前用戶 - `sudo` : 超級使用者模式 - `sudo adduser <username>` 新增使用者 - `sudo su - <username>` 切換使用者 - `sudo deluser <username>` 刪除使用者 - `last` 檢查這台電腦有誰登入過 - 放在 `/var/log/wtmp` - `man <command>` 查看指令如何用 - `q` 可以退出 - `less` 方便一頁一頁的看指令 - `whereis <command>` 告訴使用者指令放哪 - `l` 列出 whereis 找過的所有目錄 - `which`+ 指令 告訴使用者執行檔案放哪 - `type <command>` 告訴使用者是不是內建指令 >cd 是 bash 的內建指令 (builtin) >![](https://i.imgur.com/ucUdLLf.png) - `-t` 顯示指令的意義 - `apt` - `sudo apt install <package>` 下載 - `sudo apt remove <package>` 卸載 - wget + `網址`: 從此網址下載指定的內容 - dpkg - `ifconfig`: 目前有在啟動的網卡內容 - sudo ifconfig `<網卡卡號>` down : 關閉網卡 - sudo ifconfig `<網卡卡號>` up : 開啟網卡 - `a` : 顯示所有網卡內容 - `route`: routing table - n : 把可轉成數字的內容轉成數字 - `netstat`: 可以看到自己電腦網路狀況 - `-r` : 顯示 routing table - `-t` : tcp protocal? - `-u` : udp - `-n` : 文字轉數字 - `-l` : 目前系統有在監聽的檔案 - `ps` : 列出電腦有在執行的 prcoess - `a`: 列出跟 terminal 無無關的指令 - `u`: 有效使用者的 processes 列出來 - `-x` : 列出更詳細的資訊 - 火車 : 需要先安裝 `sudo apt install sl` - 執行 : `sl` - 切換使用者 : sudo su -`使用者名稱` ## web server ### /etc/nginx - `sudo service nginx start` 服務啟動 - `sudo service nginx stop` 服務暫停 - `sudo service nginx status` 查看服務狀態 - `sites-available` - default 下改 listen 的 port > 記得先備份一份 default 檔案 ,以免改錯還可以復原~ - `sudo ln -s /etc/nginx/sites-available/defalt /etc/nginx/sites-enabled` - `netstat -ntupl`: 可去檢查 port 是否有與 default 設定的一致 ## 實做

    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