Ubuntu下profile,bashrc

系統級環境變量設置

/etc/profile

這個對所有用戶有效,當用戶第一次登錄時,該文件被執行.並從/etc/profile.d目錄的配置文件中搜集shell的設置.

英文描述爲:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases Go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

/etc/environment

這個文件裏面就一個PATH環境變量,它的執行順序是晚於/etc/profile

用戶級環境變量配置

~/.profile

這個文件類似於/etc/profile,只是它是針對用戶級的,每一個用戶都會有一個自己的.profile,這個文件會調用~/.bashrc(如果存在的話)

~/.bashrc

當登錄時以及每次打開新的shell時,該文件被讀取.(每個用戶都有一個.bashrc文件,在用戶目錄下)。當修改了.bashrc的內容,不需要重啓生效,只要重新打開一個bash即可生效

臨時環境變量配置

export命令
export PATH=HOME/bin: PATH

其他配置文件

~/.bash_logout

每次退出系統時執行

系統級與用戶級執行順序

/etc/profile–>/etc/environment–>$HOME/.profile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章