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
    # Linux 2020 讀書會 — 第二次 [toc] ## Subject 1 - 檔案與目錄管理 ### 目錄跟路徑 - 絕對路徑:自根目錄(/)寫起 - Example: /etc, /etc/mysql, /home/user - 相對路徑 :不是由根目錄(/)寫起 - 從現在目前路徑的上/下層尋找 - 路徑代號: - `.`:代表此層目錄 - `..`:代表上一層目錄 - `-`:代表前一個工作目錄 - `~`:代表『目前使用者身份』所在的家目錄 - `~account`:代表 account 這個使用者的家目錄(account是個帳號名稱) - 目錄操作 - `cd` : 變換目錄 - `pwd` : 目前所在目錄 - `mkdir` :建一個新的目錄 - 補充:`mkdir -p /tmp/foo/bar/test` 可以建立多層目錄 - `rmdir` :刪除==空==目錄 - 若要刪除非空目錄且刪除此目錄(包含底下的東西)要`rm -r +目錄名稱` - 執行檔路徑的變數 - `echo $PATH` - 查找指令 or 程式的順序 ### 檔案與目錄管理 - `ls` :預設顯示非隱藏檔的檔名 - 藍色:目錄 - 白色:檔案 - 紅色:壓縮檔 - `ls -l` : 長資料串列出,包含檔案的屬性與權限等等資料 (等同於 `ll`) - `vim ~/.bashrc` : 查看、設定alias(ll, la ...) - `cp` :複製檔案 - `cp -r` :複製資料夾 - `rm -i`:在刪除之前會詢問是否要刪除 - `mv` : 移動檔案、目錄或更名 - 更名:`mv 舊檔名 新檔名` - `cat` : 列出檔案資料 - `-n` : 顯示行號 - `-b` : 顯示行號並跳過空白行 - `tac` : 反向顯示(從底下顯示) - `nl` : 列出行號 - `less` : 翻頁檢視 - `head` : 取出前面幾行(預設10行) - `head -n` : 指定輸出行數 - `tail` : 取出後面幾行(預設10行) - 推薦安裝 : [bat](https://github.com/sharkdp/bat) - 可以高亮程式碼、顯示行號 - `-f` : 如果檔案持續有輸出,會持續顯示 - `touch -m` : 這個檔案什麼時候被變動過 - 檔案與目錄的預設權限 - `umask` : 777 - 出現的後三位數字 = 目前使用者建立檔案時的預設權限值 - 和 chmod 的不同 : chmod 是由 000 往上加,而 umask 是從最高權限往下減 :::info 舉例來說 umask 後三碼顯示為 022 r、w、x 分別是 4、2、1 022 代表: (無 -w -w) 建立檔案時:(-rw-rw-rw-) - (-----w--w-) ==> -rw-r--r-- 建立目錄時:(drwxrwxrwx) - (d----w--w-) ==> drwxr-xr-x ::: - 檔案的隱藏屬性 - `chattr` (change attribute):設定檔案隱藏屬性 - `lsattr` (list attribute): 顯示檔案隱藏屬性 - 檔案的特殊權限 - SUID(Set UID) : 4 - 只對執行檔有效 (Binary Program) - 執行者必須要有執行權限 `x` - 執行的時候 (僅限 run-time) 會變成擁有者的權限 ![http://linux.vbird.org/linux_basic/0220filemanager.php#suid](https://i.imgur.com/y6GevHf.png) - SGID(Set GID) : 2 - 類似 SUID,但把使用者權限換成群組權限 - SBIT : 1 - 只有擁有者和 root 有權限刪除或移動目錄 ?! - `chmod [stickey bit]777` - 4 為 SUID - 2 為 SGID - 1 為 SBIT - 指令跟檔案的搜尋 - `which` : - 檔案檔名的搜尋 - `whereis` : 只找系統中某些特定目錄下的檔案 - 可利用 `whereis -l` 來看會找哪些目錄 - `locate` : 利用資料庫來搜尋檔名 (快) - EX:`locate -l 5 passwd` - `sudo updatedb` : 手動更新資料庫 (原先一天只會更新一次) - `find` : 直接搜尋硬碟內的檔案系統 (慢) - EX:`find / -mtime 0`找跟目錄底下往前推24小時的檔案 - EX:`find /home -user pinping`找 home 目錄下屬於 pinping 的檔案 - `find / -nogroup `找跟目錄底下 group 被刪除的檔案 - `find / -nouser `找跟目錄底下 user 被刪除的檔案 ### 補充 - `curl localhost:<port>` 查看網頁 - `tail -f`: 可看到 apache 等 server 的 log (持續追蹤 Log 輸出) - EX:`tail -f /var/log/nginx/access.log` - EXT/XFS : 系統格式可以安裝各個採用的作業系統來玩玩看 > [name=JackKuo] EXT : Linux 常見的檔案系統。就像是 NTFS, FAT 都是檔案系統,不同的檔案系統有不同特色,像是讀寫效率、可靠性、壓縮程度 - 可參考 [JackKuo 大學生涯誌](https://jackkuo.org/post/-%E6%88%91%E7%9A%84%E5%A4%A7%E5%AD%B8%E7%94%9F%E6%B4%BB-%E6%9A%A8%E5%A4%A7%E8%B3%87%E5%B7%A5/)

    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