Linux下與環境變數有關的配置檔案

2021-06-08 03:49:17 字數 782 閱讀 8851

1、

centos:

/etc/profile, /etc/bashrc

~/.bashrc, ~/.bash_profile, ~/.bash_logout, ~/bash_history

ubuntu:

/etc/profile, /etc/bash.bashrc

~/.bashrc, ~/.profile, ~/.bash_logout, ~/bash_history

2、說明(不一定正確)

①centos的~/.bash_profile相當於ubuntu的~/.profile,而且它們都會呼叫~/.bashrc

②login shell讀取配置檔案的順序:/etc/profile ----> ~/.bash_profile(~/.profile)(此外,還呼叫~/.bashrc)

③non-login shell讀取配置檔案的順序(centos):/etc/bashrc ----> ~/.bashrc

【參考資料】[bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others](

3、關於修改path

4、. 或 source 命令

. or:

source

說明:(1) 僅對當前shell有效,如果想對所有shell生效,就登出當前使用者;如果想永久生效,就重啟系統。

(2) 如果修改配置檔案使刪除某些環境變數,則執行 . 或 source 命令之後這些環境變數依然有效。

Linux有關環境變數

1 修改 etc profile 檔案 用來設定系統環境引數,比如 path.這裡面的環境變數是對系統內所有使用者生效。使用 bash 命令,需要 source etc profile 一下。2 修改 bashrc 檔案 針對某乙個特定的使用者,環境變數的設定只對該使用者自己有效。使用 bash 命...

Linux下程序與環境變數

1.在shell下可以通過命令env或set檢視當前系統的環境變數資訊。2.獲取環境變數的值 extern char getenv const char name 如果執行成功,此函式返回指定環境變數的值,否則返回null。3.新增環境變數 extern int putenv char string...

linux下的環境變數

1 設定環境變數的三種方法 1 export 臨時設定,也就是對當前會話生效 eg export lang en us 2 寫.bash profile檔案 bash profile的位置一般在 home目錄下 對當前使用者設定有效 vi bash profile 要立即生效,請使用 source ...