kyle shanks
    • 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 New
    • 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 Note Insights Versions and GitHub Sync 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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'Shell 加載 & 變量 & 環境變量' disqus: kyleAlien --- Shell 加載 & 變量 & 環境變量 === ## Overview of Content Linux 中有許多地方可以設定環境變量(environment variable),而它設定在哪也會影響到如何使用 :::success * 如果喜歡讀更好看一點的網頁版本,可以到我新做的網站 [**DevTech Ascendancy Hub**](https://devtechascendancy.com/) 本篇文章對應的是 [**Shell 全局及區域變數、特殊變數及環境變數 | Shell 啟動順序**](https://devtechascendancy.com/shell-variables_environment-shell-loading/) ::: [TOC] ## 字面常數、引號 在 Shell 中,不同「**引號**」代表的意義不同,Shell 對於命令中的引號分析如下: 1. 在執行之前 Shell 會尋找其中的變數、萬用字元、其他代數,並將其替代(至於變數部分又會與「單」、「雙」引號有關) 2. 替換完畢後,會將結果傳遞給命令 ### 單引號:不會替換 * 要建立常數最簡單的方法(或是說標準的做法)就是使用單引號,在 **單引號內的字元 ==不會==被替換**,它們將以常數的方式表現 ```shell= # $ 不會被替換 echo 'Good morning~ $PLACE_HOLDER' # * 不會被轉換 echo 'Good morning~ *' # $() 不會啟動一個新 Shell echo 'Good morning~ $(echo Apple)' ``` > 從下圖中,我們可以看到被單引號包裹的命令(`$PLACE_HOLDER`)是不會執行的 > > ![](https://hackmd.io/_uploads/Bkj5N9Eon.png) :::info * **被單引號括著的就是一個參數,如果要輸出單引號要使用跳脫字元(`\`)**: 有時候我們會碰到需要使用單引號 `'` 的時候,這時就要注意,可以使用跳過字元(反斜線 `\`) ```shell= # 這句其實輸出了三個字面參數 # 1. 'I' # 2. \' (跳脫字元) # 3. 'm Alien![](https://hackmd.io/_uploads/B1dmAq4on.png) echo 'I''\'m Aliem' ``` > ![](https://hackmd.io/_uploads/HJ-MP94o2.png) ::: ### 雙引號:替換、執行 * 雙引號與單引號最大的差別在,雙引號內的 **特殊字元會被替換、執行** ```shell= # 定義 NAME 變數 NAME=Alien # 使用單引號呼叫變呼叫數 echo 'What up $NAME' # 使用雙引號呼叫變呼叫數 echo "What up $NAME" ``` > 如下圖所示,變數 `NAME` 確實會在執行時被替換 > > ![](https://hackmd.io/_uploads/B1QUH94o2.png) ## 環境變量概述 bash shell 用一個叫作 **環境變量** (`environment variable`) 的特性來存儲有關 shell 和工作環境的信息 > 變量儲存在記憶體(內存)中 Bash shell 中,環境變量主要分為兩類:^1.^ **局部變量**、^2.^ **全局變量** ### 讀取局部變量:set * 局部變量只會讓創建變量的 Shell 本身訪問(其他的 Shell,包括 `sub shell` 也不可訪問);如果要查看全部的局部變量,可以執行以下命令 | 命令 | 說明 | | - | - | | set | 列出所有全局、局部變量 (並且會對變量進行排序) | ```shell= ## 列出所有全局、局部變量 set ``` :::info 局部變量一般來說都用小寫,全局變量則使用大寫 ::: ### 設定/移除局部變量:unset * **設定局部變量**:簡單使用,變量名`=` 變量,就可以設定局部變量 ```shell= echo $my_local_variable ## 設定局部變量 my_local_variable="Hello local variable." echo $my_local_variable ## 查看局部變量 set | gerp my_local ``` :::warning * **設定 Shell 變量時的注意事項** 1. 變量最好使用**單(或雙)引號包裹**起來,不然 **空格會被誤認變量已設定完成** > 錯誤範例:my_local_variable=Hello local variable. 2. 賦予值時 **`=` 之間不要使用空格空開,否則 Shell 會解讀為單獨命令** > 錯誤範例:my_local_variable = "Hello local variable." ::: > ![](https://i.imgur.com/Jsy80n9.png) :::warning * **在子進程中無法獲取父進程的局部變量**;不過如果使用 [**進程列表**](https://devtechascendancy.com/command-line_shell-type_sub-shell_builtin/#%E9%80%B2%E7%A8%8B%E5%88%97%E8%A1%A8%EF%BC%9Acreate_sub_shell) 的方式創建 sub shell 就可以獲取父進程局部變量 ```shell= echo $my_local_variable ## 創建 sub shell bash ## 查看進程 ps --forest ## sub shell 不可訪問 parent shell 的局部變量 echo $my_local_variable ## 退出 sub shell exit ## 回在 parent shell 就可以訪問 echo $my_local_variable ``` > ![](https://i.imgur.com/I2wQ3il.png) ::: * **移除局部變量**:使用 `unset` 命令就可以移除局部變量;移除時不需使用 `$` 符號 ```shell= echo $my_local_variable ## 移除局部變量 unset my_local_variable echo $my_local_variable ## 查看局部變量 set | gerp my_local ``` > ![](https://i.imgur.com/QI6TdMB.png) ### 全局變量:env/printenv * 全局環境變量就是所有 Shell 會話都可以訪問的變量;查看全局變量的命令如下 | 命令 | 說明 | | - | - | | env | 列出所有全局變量 | | printenv [指定變量] [指定變量] ... | 同上,不過它可以指定變量 | ```shell= ## 只列出前 10 項全局變量 env | head ## 列出指定變量 printenv SHELL ## 可指定多個 printenv SHELL HOME ``` > ![](https://i.imgur.com/oTXF4h3.png) ### 設定/移除全局變量:export * **創建全局變量**:使用 `export` 命令就可以創建一個全局變量 (變量創建方式與設定局部變量相同) **透過 `export` 創建的變量就可以讓 sub shell 訪問到** :::info * **sub shell 取得的是原本變量的參照**? 不是~ sub shell 取得的是一個 **變量副本**,sub shell 可以改變變量的值,但是無法影響到外部變量(不會影響到原本的變量) ::: ```shell= ## 創建全局變量 export my_export_variable="Hello export variable." echo $my_export_variable ## create sub shell bash ## 讀取外部全局變量 echo $my_export_variable ## 修改變量副本 my_export_variable="Fix!" ## 讀取修改後的副本內容 echo $my_export_variable ## exit sub shell exit ## 讀取外部變量(不受內部修改影響) echo $my_export_variable ``` > ![](https://i.imgur.com/EWbOpa7.png) * 刪除全局變量,同樣使用 `unset` 命令 ```shell= unset my_export_variable ``` ## 特殊參數 bash 中附有幾個「**特殊參數**」,可以透過這些特殊參數來達到你要的功能 ### Shell 腳本讀取參數:`$` 我們可以對腳本傳入需要的參數,像是如下 ```shell= # add 是腳本 # 10、20 就是參數 add 10 20 ``` * Shell 會將輸入參數稱為 位置参數 (**positional parameter**),其參數有部分限制、特性: * **參數順序以 `0` 開始計算**! * **第一個參數 `$0` 一定是腳本本身的名稱**! * 參數取用方式 `$參數順序`,**當參數數量超過 9 時,必須要花括號來包裹 `${參數順序}`** > e.g: > 第 3 個參數 -> `$2` > 第 12 個參數 -> `$11` * 以下透過讓使用者輸入一個參數,實現階乘 `factorial` 的運算 ```shell= #!/bin/bash factorial=1 userSet=$1 for (( a = 1; a <= userSet; a++ )) ; do (( factorial *= a )) echo "$a: $factorial" done echo "The factorial of $userSet is $factorial." ``` > ![](https://i.imgur.com/kn8wxwt.png) :::info * 如果你要輸入更多的參數,請使用 **空格** 區分不同參數 * 如果輸入的參數有包含空格,需使用單引號(雙引號也可以)包裹空格 ::: :::warning * 使用參數時,建議使用 test 命令(`-n`、`-z`)來測試參數是否存在,避免取不到參數的錯誤 ::: ### Shell 腳本取得參數總數:`$#` * `$#` 符號可以取得使用者輸入的參數總數,**這個參數總數不包括腳本本身,也就是不包括 `$0`** :::warning * **符號特殊改變**: 有個特殊情況,如果外部已經用「$ + 花括號, `${ }`」包裹,那取參數總數的方式就會變成 `${!#}`;**花括號內不能用 `$`,要改用 `!`** > 使用 `${!#}` 時,如果參數總數為 0,則輸出腳本自身 ::: * 取得輸入給 Shell 腳本參數總數的範例: ```shell= #!/bin/bash tpc=$# echo "total param count = $tpc" echo "total param count = ${!#}" if [ $tpc -lt 2 ] ; then echo "param too less" elif [ $tpc -gt 2 ] ; then echo "param too more" else echo "result: $[ $1 + $2 ]" fi ``` > ![](https://i.imgur.com/Qh9mFVK.png) ### Shell 腳本取得所有參數:`$*`、`$@` 差異 * `$*`、`$@` 兩個符號都可以取得所有參數,不過他們兩個還是有不同的地方;**差異點在於對於看待參數時是否分離** | 符號 | 特點 | | - | - | | $* | 將所有參數視為一個個體(整體) | | $@ | 將所有參數分開看待 | * Shell 讀取所有參數的範例: ```shell= #!/bin/bash for tmp in "$*" ; do echo "\$*: $tmp" done for tmp in "$@" ; do echo "\$@: $tmp" done ``` 從下圖中,我們可以看到 `$*` 確實將全部的參數視作一個整體 > ![](https://i.imgur.com/NwrwyR3.png) ### 取得上次命令退出碼:`$?` * 使用 `$?` 可以取得上次執行的命令的退出碼(這邊要特別注意的是,**`$?` 符號只保存最近一次**,它不會保存超過一次以上的退出碼);範例如下… ```shell= echo "HelloWorld" echo $? ls 123 echo $? ``` > ![](https://hackmd.io/_uploads/HyIQvCUL2.png) ### 自身 Shell PID:`$$` * **使用 `$$` 符號,就可以獲取當前使用的 Shell PID**;範例如下… ```shell= echo $$ ``` > ![](https://hackmd.io/_uploads/By10A_dLn.png) ## Shell 更多不同變量的變量 除了上述的基礎定義 Shell 變量的方法外,Shell 也可以定義 array 變量、默認變量、PATH 變量... 等等 ### Shell 數組變量:Array 變量 * 數組(`Array`)變量在賦予值時,是放置在括號內,並使用空格區分開;格式說明如下表 | 功能 | 格式說明 | e.g | | - | - | - | | 宣告 | 放置在括號 `()` 內,並使用空格 (` `) 區分開 | `MyArray=(A B C D E F G)` | | 單個值 | 數組變數放置花括號 `{}` 內,並使用中括號 `[]` 指定 | `${MyArray[2]}` | | 全部值 | 同上,不過中括號內使用 `*`,**將全部數據視為++一個數據++** | `${MyArray[*]}` | | 全部值 | 同上,不過中括號內使用 `@`,**它會將數組中的數據 ++單獨++ 展開** | `${MyArray[@]}` | | 取消變數 | 使用 unset | - | ```shell= ## 宣告並設定值 MyArray=(A B C D E F G) ## 預設取出第一個 echo $MyArray ## 取單個值 echo ${MyArray[2]} ## 取全部值 echo ${MyArray[*]} ## 取消變數 unset MyArray echo ${MyArray[*]} ``` > ![](https://i.imgur.com/RatgVYd.png) * 另外一個 Shell 數組變量的宣告方式,使用大括號 `{}`: **大括號宣告陣列(`array`)還可以指定「間距」**,格式為 `{first..last..step}`,其中 `step` 就代表了間距;範例如下 ```shell= for VAL in {0..10..2}; do; echo "$VAL"; done ``` > ![image](https://hackmd.io/_uploads/BJ2sBt-06.png) ### 默認 Shell 變量 * 默認情況下,Bash shell 會用一些**特定的變量來定義系統環境** (這些特定變量就是默認 Shell 變量);以下列出幾個常見變量(默認環境變量有很多,如有需要請查表) > 這些默認變量並非一定有值,有可能為空 | Shell 變量 | 功能描述 | | - | - | | HOME | 當前用戶目錄 | | IFS | 用來切割文本的字符串 | | PS1 | Shell 命令 主提示 符號 | | PS2 | Shell 命令 次提示 符號 | | PS3 | Select 命令 提示 符號 | | EUID | 當前用戶的有效用戶 ID | | BASH | 當前 Shell 實例的全路徑名 | | BASH_ENV | Shell 腳本啟動前會嘗試運行該變量定義的 **啟動文件** | | GROUPS | 當前用戶的群組 | > ![image](https://hackmd.io/_uploads/H1SfCeuJ0.png) :::info * 默認變量可以使用 `set` 指令列出 但同時也要注意,不是所有默認環境變量都會在運行 `set` 命令時列出 ::: ### PATH 環境變量:暫時環境變量 * PATH 環境變量用於進行命令、程序查找的目錄;當使用外部命令時,就會去查找 PATH 變量中的路徑,並在這些路徑下找命令 ```shell= echo $PATH ``` > 路徑之間使用 `:` 隔開 > > ![](https://i.imgur.com/ElbYZoJ.png) * 這裡來說明,**如何暫定 PATH 變量** **暫時環境變量的生命週期只會依存於 Shell 的命生週期**,如果 Shell 結束,這個暫定的 PATH 變量也會結束;範例如下… ```shell= echo $PATH ## 新增路徑(使用 `:` 隔開) PATH=$PATH:/home/alien/Desktop/test ## 再次查看 PATH 就會發現有新增 echo $PATH ``` > ![](https://i.imgur.com/sYXh1GP.png) :::success * 如果希望 sub shell 也可以使用自己的 PATH,那在定義時就要加入 `export` 關鍵字 ```shell= export PATH=$PATH:/home/alien/Desktop/test ``` ::: ## Shell 的啟動 & 環境變量 如果要讓環境變量永久化,那就要將環境變量設定寫入 **某些文件**;所以這裡我們要先來 **討論 Shell 的啟動 & 環境變量的關係** * **Shell 啟動一般來說有以下幾種方式** 1. **登入式**:登入帳號默認的登入 Shell;可以是透過 `/bin/login`, `SSH` ... 等等方式從中端登入,這些方式就稱為 登入式 Shell > 每個帳號預設的 Shell 2. **交互式**:非登入 Shell;如同登入帳戶後,在 Linux GUI 中開啟的 Shell > sub shell 的概念 3. **腳本式**(又稱為非交互式):作為腳本運行的 Shell > 腳本 Shell 其實就是文本,而文本在開頭就會指定 shell 類型; > > e.g : `#!/bin/bash` ### Shell 提示字元 * 我們可以透過設定 `PS1` 變量來改變當前 Shell 視窗的提示字元 :::warning * 替換字元不要使用 Shell 關鍵字 (不要用 `<`、`>`、`&`、`{}`、`=` ... 等等符號) ::: 替換格式如下 ```shell= PS1='<替換關鍵字>' ``` 常用 替換關鍵字 如下 | 關鍵字 | 功能 | | - | - | | `\u` | 當前使用者名 | | `\h` | Host 名稱 | | `\!` | 當前已輸入的指令號(History 統計數量) | | `\w` | 當前完整目錄 | | `\W` | 當前目錄(只有目錄,沒有全路徑) | | `\$` | 依照權限顯示,如果是使用者顯示 `$` 符號,如果是管理者則顯示 `!` 符號 | ```shell= # User 名稱 # Host 名稱 # 指令號 # 當前目錄 # 權限顯示 PS1='\u@\h(\!)\W\$' ``` > ![](https://hackmd.io/_uploads/SyofKZRon.png) ### 登入 Shell:加載順序 * 登入的 Shell 會從「5 個」不同的文件中讀取命令,而這些文件的讀取也是有順序的,順序功能如下 1. **`/etc/profile` 內會呼叫並讀取 `/etc/profile.d` 目錄,該目錄會保存多個 sh 腳本** | 文件 | 功能 | 補充 | | - | - | - | | `/etc/profile` | 主啟動文件 | 每個用戶登入時都會加載該文件 | ```shell= ## 查找關鍵字 cat /etc/profile | gerp -A 10 profile ls -laF /etc/profile.d/ ``` > 可以發現腳本內會讀取 `/etc/profile.d` 目錄中所有 `.sh` 結尾的文件 > > ![](https://i.imgur.com/H1Z70Uk.png) 2. 接下來就是登入用戶後(針對用戶,可根據需求訂製),會加載的啟動文件(每個發行版使用的文件不同) | 加載順序 | 文件 | 補充 | | - | - | - | | 1 | `$HOME/.bash_profile` | - | | 2 | `$HOME/.bash_login` | - | | 3 | `$HOME/.profile` | - | | - | `$HOME/.bashrc` | **該文件是透過其他文件被加載** | :::warning **並非每個文件都存在**,大部分 Linux 發行版都只會使用這些文件的 1 ~ 2 個 ::: ```shell= ## Ubuntu 22 中是透過 `$HOME/.profile` 文件加載 `$HOME/.bashrc` cat ./.profile | grep bashrc ``` > ![](https://i.imgur.com/58zShdd.png) ### 交互式 Shell * 交互式 Shell 也就是 sub shell,**它在是在登入後才啟動的 Shell,所以自然不會讀取 `/etc/profile` 文件**; **交互式 Shell 會讀取 `$HOME/.bashrc` 文件** ```shell= cat .bashrc | grep -v -E "^#" ``` :::info * **`.bashrc` 有幾個作用** 1. 加載查看 `/etc/bash.bashrc` 2. 載入用戶設定的別名 (`alias`) ::: ### 非交互式 Shell * 非交互式 Shell (Shell 腳本) 啟動時會先檢查 `BASH_ENV` 全局變量,並去讀取它的值去加載啟動文件 > `BASH_ENV` 不一定會有設定值 ```shell= printenv BASH_ENV ``` 一般來說 sub shell 會導出父 shell 的變量來使用 (記得用 `export`) ### 永久化環境變數 * 一般來說可以寫在以下兩個文件中 | 寫入文件 | 注意事項 | | - | - | | `/etc/profile` | **更新系統版本後就會被刷掉**,最好是改成在 `/etc/profile.d` 目錄下創建一個 `.sh` 文件 | | `$HOME/.bashrc` | 可適用於大多數 Shell,如果是非交互式 Shell 則要注意 `BASH_ENV` 設定 | ## Appendix & FAQ :::info ::: ###### tags: `Linux Shell`

    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