導讀 | 使用終端ssh登陸Linux操做系統的控制檯後,會出現一個提示符號(例如:#或~),在這個提示符號以後能夠輸入命令,Linux根據輸入的命令會作迴應,這一連串的動做是由一個所謂的Shell來作處理。Shell是一個程序,最經常使用的就是Bash,這也是登陸系統默認會使用的Shell。 |
• 對於個別用戶的啓動配置文件linux
用戶HOME(家)目錄/.bashrcshell
head -1 ~/.bashrc # ~/.bashrc: executed by bash(1) for non-login shells.
用戶HOME(家)目錄/.profilebash
head -1 ~/.profile # ~/.profile: executed by Bourne-compatible login shells.
• 對於所有用戶的啓動配置文件ssh
head -1 /etc/bash.bashrc # System-wide .bashrc file for interactive bash(1) shells. head -2 /etc/profile # /etc/profile: system-wide .profile file for the Bourne shell (sh(1) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
• bashrc和profile的差別ide
從上面的英文描述能夠知道,bashrc和profile的差別在於: 1. bashrc是在系統啓動後就會自動運行。 2. profile是在用戶登陸後纔會運行。 3. 進行設置後,可運用source bashrc命令更新bashrc,也可運用source profile命令更新profile。 PS:一般咱們修改bashrc,有些linux的發行版本不必定有profile這個文件,本文用的系統是Ubuntu 15.10 4. /etc/profile中設定的變量(全局)的能夠做用於任何用戶,而~/.bashrc等中設定的變量(局部)只能繼承/etc/profile中的變量,他們是"父子"關係。
• 補充介紹操作系統
另外,須要補充說明介紹bashrc相關的幾個文件:
~/.bash_profile: 每一個用戶均可使用該文件輸入專用於本身使用的shell信息,當用戶登陸時,該文件僅僅執行一次!默認狀況下,他設置一些環境變量,執行用戶的.bashrc文件。
~/.bash_logout: 當每次退出系統(退出bash shell)時,執行該文件。
~/.bash_profile 是交互式、login方式進入bash運行的,~/.bashrc是交互式non-login方式進入bash運行的,一般兩者設置大體相同,因此一般前者會調用後者。繼承
原文來自:http://www.ttlsa.com/linux/linux-bashrc-and-profile/get