自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux bashrc和profile的用途和區(qū)別

系統(tǒng) Linux
使用終端ssh登錄Linux操作系統(tǒng)的控制臺后,會出現(xiàn)一個提示符號(例如:#或~),在這個提示符號之后可以輸入命令,Linux根據(jù)輸入的命令會做回應(yīng),這一連串的動作是由一個所謂的Shell來做處理。

[[175254]]

使用終端ssh登錄Linux操作系統(tǒng)的控制臺后,會出現(xiàn)一個提示符號(例如:#或~),在這個提示符號之后可以輸入命令,Linux根據(jù)輸入的命令會做回應(yīng),這一連串的動作是由一個所謂的Shell來做處理。

Shell是一個程序,最常用的就是Bash,這也是登錄系統(tǒng)默認會使用的Shell。

bashrc和profile都是Shell的啟動設(shè)置文件(其實這兩個文件也是Shell腳本),可以為當前的Shell初始化環(huán)境變量等,它們類似Microsoft DOS/Windows下的autoexec.bat文件。

下面詳細介紹bashrc和profile的用途和區(qū)別:

針對個別用戶

 

  1. .bashrc  
  2. # ~/.bashrc: executed by bash(1) for non-login shells.  
  3. .profile  
  4. # ~/.profile: executed by Bourne-compatible login shells. 

針對全體用戶

 

  1. /etc/bash.bashrc  
  2. # System-wide .bashrc file for interactive bash(1) shells.  
  3. /etc/profile  
  4. # /etc/profile: system-wide .profile file for the Bourne shell (sh(1) 

 

bashrc和profile的差異

從上面的英文描述可以知道,bashrc和profile的差異在于:

1. bashrc是在系統(tǒng)啟動后就會自動運行。

2. profile是在用戶登錄后才會運行。

3. 進行設(shè)置后,可運用source bashrc命令更新bashrc,也可運用source profile命令更新profile。

PS:通常我們修改bashrc,有些linux的發(fā)行版本不一定有profile這個文件

4. /etc/profile中設(shè)定的變量(全局)的可以作用于任何用戶,而~/.bashrc等中設(shè)定的變量(局部)只能繼承/etc/profile中的變量,他們是”父子”關(guān)系。

補充介紹

另外,需要補充說明介紹bashrc相關(guān)的幾個文件:

~/.bash_profile: 每個用戶都可使用該文件輸入專用于自己使用的shell信息,當用戶登錄時,該文件僅僅執(zhí)行一次!默認情況下,他設(shè)置一些環(huán)境變量,執(zhí)行用戶的.bashrc文件。

~/.bash_logout: 當每次退出系統(tǒng)(退出bash shell)時,執(zhí)行該文件。

~/.bash_profile 是交互式、login方式進入bash運行的,~/.bashrc是交互式non-login方式進入bash運行的,通常二者設(shè)置大致相同,所以通常前者會調(diào)用后者。

責任編輯:未麗燕 來源: 程序師
相關(guān)推薦

2020-08-12 23:13:01

Linux.bashrc.bash_profi

2009-12-03 10:12:24

LinuxUnix

2011-09-05 17:44:49

LinuxUnix

2021-07-26 10:42:49

云計算AIOps人工智能

2017-08-22 14:26:39

Linuxbuffercache

2021-11-01 10:05:32

Linuxsusudo

2013-05-03 10:21:53

CentOSRedHat Linu

2022-03-25 13:39:40

區(qū)塊鏈技術(shù)房地產(chǎn)

2009-06-23 18:56:51

2018-08-03 09:07:40

Linux內(nèi)存buffercache

2018-11-20 13:48:47

Linux命令more

2009-12-02 14:50:28

操作系統(tǒng)

2010-07-02 12:31:35

UML對象圖

2009-07-17 09:51:03

LinuxLinux開發(fā)Linux使用

2018-07-20 14:00:51

LinuxmacOS內(nèi)核

2018-09-20 16:10:48

CookiesSession前端

2010-08-12 15:30:27

FlexFlash

2019-11-01 11:06:02

Linux操作系統(tǒng)Windows

2020-06-01 19:00:42

Linux軟鏈接硬鏈接

2022-09-08 18:38:26

LinuxWindowsmacOS
點贊
收藏

51CTO技術(shù)棧公眾號