export PATH=$PATH:/etc/apache/bin
登出或重開機後失效。
vi /etc/profile
# 在適當位置加入
export PATH=$PATH:/etc/apache/bin
# 注意等號兩邊不能有空格
vi ~/.bash_profile
# 修改 PATH 行,附加新路徑
source /etc/profile
# 或
. /etc/profile
原理:source 在當前 Shell 進程執行腳本,環境變數變更會保留;若用 sh /etc/profile 會開啟子 Shell,變更不會回傳給父進程。
echo $PATH