Editing
How to setup my system path
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Windows, Linux 或 Mac 作業系統如何設定系統 PATH == Windows 如何設定系統 PATH == * Windows XP: Windows 檔案總管 -> 在「我的電腦」按滑鼠右鍵 -> 選擇選單的「內容」 --> 「系統內容」視窗 -> 切換到「進階」標籤 -> 點選「環境變數」按鈕 * Windows 10: Windows 檔案總管 -> 在「本機」按滑鼠右鍵 -> 選擇選單的「內容」 --> 檢視電腦的基本資訊 --> 點選「進階系統設定」連結 --> 「系統內容」視窗 -> 切換到「進階」標籤 -> 點選「環境變數」按鈕 : http://farm2.static.flickr.com/1051/938375025_50edbc0819_o.png : (Image host on [http://www.flickr.com/photos/planetoid/938375025/ Flickr]) * 「環境變數」視窗 -> 點選「系統變數」的「Path」 -> 點選「編輯」按鈕 : http://farm2.static.flickr.com/1049/938375087_0857140c5d_o.png : (Image host on [http://www.flickr.com/photos/planetoid/938375087/ Flickr]) Path內有多個資料夾路徑。不同資料夾用分號(;)間隔,例如<pre>C:\Program Files\MiKTeX 2.6\miktex\bin;c:\usr\bin;C:\usr\site\bin;C:\usr\bin;</pre> 如果使用命令提示字元,需要關閉再重開啟命令提示字元,才能套用新的路徑設定。 如何驗證新的路徑設定: {{kbd | key= echo %PATH%}} ({{Win}}) == Linux 如何設定系統 PATH == 假設新安裝的程式在 {{kbd | key=<nowiki>/Users/電腦帳號/.rvm/bin</nowiki>}} 新增程式到 PATH <pre> export PATH="$PATH:$HOME/.rvm/bin" </pre> 重新開啟終端機 (terminal),驗證有無加入 PATH <pre> echo $PATH </pre> == Mac 如何設定系統 PATH == 新增程式目錄 {{kbd | key=<nowiki>~/path/to/scripts</nowiki>}} 到 PATH 1. 打開編輯器編輯 {{kbd | key=<nowiki>~/.zshrc </nowiki>}} 使用 {{kbd | key=<nowiki>echo $SHELL</nowiki>}} 得到結果 {{kbd | key=<nowiki>/bin/zsh</nowiki>}}。代表使用 [https://zh.wikipedia.org/zh-tw/Z_shell Zsh] 作為預設的 shell,會預設載入 {{kbd | key=<nowiki>~/.zshrc </nowiki>}} 設定檔 <ref>[https://tommcfarlin.com/shells-in-macos/ A Quick Guide to Shells in macOS | Tom McFarlin]</ref><ref>[https://support.apple.com/zh-tw/guide/terminal/trml113/mac 在 Mac 上的「終端機」中更改預設 Shell - Apple 支援 (台灣)]</ref>。 2. 新增下面一行 <pre> export PATH="$HOME/path/to/scripts:$PATH" </pre> 3. 重新啟動終端機,或者直接輸入指令,立即套用更改而不重新啟動終端機或登出,動態更新當前 shell 環境的設定。 <pre> source ~/.zshrc </pre> 4. 驗證有無加入 PATH <pre> echo $PATH </pre> 其他 shell 設定檔: <pre> cat ~/.bash_profile cat ~/.bashrc cat ~/.profile </pre> == Linux 如何設定系統環境變數 == Linux 如何設定系統環境變數、環境變量 (environment variable) 假設你已經把 Java 裝在了這個路徑上:(/usr/lib/jvm/jjava-1.8.0-openjdk-1.8.0.402.b06-1.el7_9.x86_64/jre/bin),意味著你的 Java 執行文件位置是在 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5.x86_64/jre/bin/java。在這種情況下,你能通過 bash shell 或是編寫腳本的方式,來指定 JAVA_HOME 環境變量,如下所示:<ref>[https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora How To Install Java on CentOS, Rocky Linux, RHEL, and Fedora | DigitalOcean]</ref> <pre> $ sudo sh -c "echo export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.402.b06-1.el7_9.x86_64/jre >> /etc/environment" </pre> == 相關資料 == * [http://www.windowsitpro.com/Article/ArticleID/48074/48074.html How can I add a new folder to my system path?] * [[MS Windows Explorer]]: Windows檔案總管的捷徑屬性 與 Windows2000/XP環境變數 * [[Linux commands#specify_the_location_where_Linux_or_MS-DOS_looks_when_using_a_command | specify the location where Linux or MS-DOS looks when using a command]] == 參考資料 == <references /> [[Category: System]] [[Category: Windows]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Kbd
(
edit
)
Template:Win
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information