Linux中profile、bashrc、bash_profile之间的区别和联系
/etc/profile:此文件為系統(tǒng)的每個用戶設(shè)置環(huán)境信息,當(dāng)用戶第一次登錄時,該文件被執(zhí)行.并從/etc/profile.d目錄的配置文件中搜集shell的設(shè)置.
英文描述為:
# /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/profile有修改的話必須得重啟你的修改才會生效,此修改對每個用戶都生效。
/etc/bashrc:為每一個運行bash shell的用戶執(zhí)行此文件.當(dāng)bash shell被打開時,該文件被讀取.
英文描述為:
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# 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.
如果你想對所有的使用bash的用戶修改某個配置并在以后打開的bash都生效的話可以修改這個文件,修改這個文件不用重啟,重新打開一個bash即可生效。
~/.bash_profile:每個用戶都可使用該文件輸入專用于自己使用的shell信息,當(dāng)用戶登錄時,該文件僅僅執(zhí)行一次!默認(rèn)情況下,他設(shè)置一些環(huán)境變量,執(zhí)行用戶的.bashrc文件.
此文件類似于/etc/profile,也是需要需要重啟才會生效,/etc/profile對所有用戶生效,~/.bash_profile只對當(dāng)前用戶生效。
~/.bashrc:該文件包含專用于你的bash shell的bash信息,當(dāng)?shù)卿洉r以及每次打開新的shell時,該文件被讀取.(每個用戶都有一個.bashrc文件,在用戶目錄下)
~/.bash_logout:當(dāng)每次退出系統(tǒng)(退出bash shell)時,執(zhí)行該文件.?
另外,/etc/profile中設(shè)定的變量(全局)的可以作用于任何用戶,而~/.bashrc等中設(shè)定的變量(局部)只能繼承/etc/profile中的變量,他們是"父子"關(guān)系.
?
~/.bash_profile 是交互式、login 方式進入bash 運行的;
~/.bashrc 是交互式 non-login 方式進入bash 運行的;
通常二者設(shè)置大致相同,所以通常前者會調(diào)用后者。
總結(jié)
以上是生活随笔為你收集整理的Linux中profile、bashrc、bash_profile之间的区别和联系的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: /etc/bashrc和/etc/pro
- 下一篇: linux 其他常用命令