蓬萊人偶
    • 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
    [TOC] - Book mode: https://hackmd.io/@ncnu-opensource/book # FHS、基礎指令 ## 講古 - Multics - MULTiplexed Information and Computing System - **Unix** 不多工 - UNIX(非複用資訊和計算機服務,英語:Uniplexed Information and Computing Service,UnICS)[(source: 維基百科)](https://zh.wikipedia.org/wiki/UNIX) ## 重要概念 - 萬物皆檔案(硬體也是!) - inode 來找到檔案放在磁碟中哪些 block - 多使用者作業系統 ::: info BT 補充: ㄉㄤ對齊會比較有效率 也要看檔案系統???? ::: :::info `finger` 可以看到現在登入在這台機器上的人的資料 ::: :::info ##### 偷看別人用了什麼系統的方法: - Shodan - Nmap <iframe src="https://app.warp.dev/block/embed/vx4orfzV8YszrwUwSW7ic2" title="NMAP Demo" style="width: 1612px; height: 255px; border:0; overflow:hidden;" allow="clipboard-read; clipboard-write"></iframe> ::: ##### 偷看自己系統是什麼 <iframe src="https://app.warp.dev/block/embed/IbyrGM29ieppKGlR9sx3ZV" title="embedded warp block" style="width: 1810px; height: 255px; border: 0; overflow:hidden;" allow="clipboard-read; clipboard-write"></iframe> > neofetch 已 Archive > 哭哭 ## 指令 - `cd`:<font color="#f00">C</font>hange <font color="#f00">D</font>irectory,這個指令用來切換工作目錄,讓你能快速跳轉到你所需的路徑 - `ls`:<font color="red">List</font> ,這個指令會將當前目錄下的所有檔案和資料夾列出來,讓你清楚看到目錄中的內容 - `sl`:<font color="red">S</font>team <font color="red">L</font>ocomotive如果不小心地把 `ls` 寫成 `sl`,會召喚一台火車從螢幕中呼嘯而過,:steam_locomotive::steam_locomotive::steam_locomotive: - `cat`:印出檔案 - `tac`:反向印出檔案 - `sudo`:讓他們執行一些只有系統管理員或其他特定帳號才能完成的任務 - `nano your_file_name`:編輯檔案內容 - ^c 中斷目前進行中的程式 - ^z 暫停程式但不中斷,使用 `fg` 來回到背景執行的程式 - ^l 清空目前畫面,或是 `clear`,clear 會完全清空螢幕,`^l`則是將畫面捲到最上層 > ^ 是 ctrl 的意思 ## FHS 檔案系統階層標準 ![image](https://hackmd.io/_uploads/HJmn7jf0R.png) Windows 中,早期 A 槽和 B 槽是讀磁片 C ~ Z 硬碟(再多要 mount) ## 萬物皆檔案 ## Linux 檔案權限 * **多使用者作業系統** #### ls 列出現在目錄底下有哪些檔案 <iframe src="https://app.warp.dev/block/embed/cMaL3lpidESWnsAiq733Al" title="embedded warp block" style="width: 1612px; height: 255px; border:0; overflow:hidden;" allow="clipboard-read; clipboard-write"></iframe> * `/` = root:根目錄 * `/bin` = Binary * 查看是否為可執行的二進位檔案 ```= file /bin/ls /bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=36b86f957a1be53733633d184c3a3354f3fc7b12, for GNU/Linux 3.2.0, stripped ``` ##### `cat /bin/ls` <iframe src="https://app.warp.dev/block/embed/9TV9blGZYrBDRWecZHCS4U" title="embedded warp block" style="width: 1612px; height: 255px; border:0; overflow:hidden;" allow="clipboard-read; clipboard-write"></iframe> #### `ls /bin` <iframe src="https://app.warp.dev/block/embed/qRFEXCOcOzQr6a29Vzi8H8" title="embedded warp block" style="width: 1612px; height: 255px; border:0; overflow:hidden;" allow="clipboard-read; clipboard-write"></iframe> #### `/sbin` Super user Binaries * 開機過程需要用到的檔案 * 開機、修復、復原系統所需要用到的指令 * 避免亂用以免harm to system!!! * 透過 `/ls bin` 查看一般使用者可以下的指令 * bootstrap存在boot下 #### `/dev` device(考試會考) - a special filesystem that contains device files - `/dev/tty` : 放 terminal 的檔案 - `/dev/null`: 任何寫到 `/dev/null` 的資料都會消失,常用來消除不需要的輸出 - `echo "test" > /dec/null` - 將 `test` 這段文字內容 `>` standard output 到 `/dev/null` - `/dev/zero`: ```bash= sudo cat /dev/input/mice ``` > 隨著滑鼠移動,會有資料輸出,動態產生內容,用`^C` 跳出來 ```bash= lspci ``` > 列印出主機板的設備 :::danger **把電腦毀滅的指令** ```bash= sudo rm -rf --no-preserve-root / ``` - sudo:Super User DO,以超級使用者(root)權限執行後續命令。 - rm:Remove,用於刪除檔案或目錄。 - -r:Recursive,遞迴地刪除目錄及其內所有檔案和子目錄。 - -f:Force,強制刪除,忽略不存在的檔案且不會顯示任何錯誤訊息。 - --no-preserve-root:取消保護根目錄的選項。預設情況下,rm 命令會保護根目錄(/),防止誤刪除整個系統。 - /:根目錄 >快照是個好工具:camera: ::: #### `/etc` 存放各種 config 檔案 - `/etc/passwd` 儲存使用者的資料,包含username、group,注意 password 欄位是空的 - 真正的密碼儲存在 `/etc/shadow`的第二個欄位,以加密的方式儲存。 - 需使用 `sudo` 才能查看 - 密碼欄位為`*`、`!`代表不能用這個 user 登入。 #### `lib` Library - 在開機時會用到的函式庫 #### `/media` - 放置可移除裝置 ex:USB、CD等掛件 ```bash= cd /media/<username> # 查案目前路徑 pwd # 插入隨身碟 # 可以看到隨身碟的檔案出現或其他掛載的設備 ls # cd 進去看 cd /disk # 目前所有掛載到電腦的裝置 lsblk cd /mnt # 建立資料夾,名字為 usb sudo mkdir usb # 掛載資料夾,把 /dev/sdb1 掛載到 /mnt/usb sudo mount /dev/sdb1 /mnt/usb/ # 查看有無成功,用 ls 看裡面有無檔案 ls ``` ```bash # 刪除資料夾 rmdir dir_name # 或 rm -r dir_name ``` * 比較`/dev`、`/mnt`、`/media` | 目錄 | 目錄內容 | | -------- | -------- | | `/dev` | 放置硬體設備的**檔案** | | `/mnt` | **手動掛載**的可移除裝置 | | `/media` | 放置**自動掛載**的可移除裝置 | > `!!` 執行上一個指令 > `history` 看所有下過的指令,包含其history_number > `!history_number` 執行特定歷史編號的指令。 > ```bash= > ls > history > # 2077 ls > # 2078 history > !2077 # 執行 ls 指令 > ``` #### `/opt` optinal * 第三方軟體放置的目錄 #### `/run` - 存放系統運行時需要臨時數據 #### `/srv` service - 放置一些網路服務啟動後,這些服務所需要取用的資料目錄 #### `/tmp` temporary - 放暫存檔 rwxrwxrwt - 執行權限`t` : 不能刪別人的 tmp 檔案 #### `/home` - 每個 user 都有自己的 `home` 目錄 #### `/root` - Linux 系統中的 kami da #### `/lost+found` - 當檔案系統發生錯誤時,會把一些遺失片段放這 #### `/proc` - 存放 process 資訊 - 虛擬的,不占用任何硬碟空間,資料存在記憶體東 #### `/sys` - 虛擬的,不占用任何硬碟空間,資料存在記憶體東 - 紀錄kernal ### link - `ls -i` 可以看到 inode(對應到磁區的位置) - softlink - `ln -s source_file link_name` - 兩個 link 的 inode 會不一樣 - hardlink - `ln source_file link_name` - 兩個 link 的 inode 會一樣 - 共用磁碟空間一樣 - 改寫一個檔案,另一個也會做一樣的變動 > 常見的文字編輯器 : nano(初階者建議使用)、vim

    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