日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux bash文件,linux之bash配置文件

發(fā)布時間:2025/3/15 linux 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux bash文件,linux之bash配置文件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

為何我們登錄linux后默認(rèn)有很多環(huán)境變量?

首先我們登錄bash有兩種方式:login shell和non-login shell;

login shell:取得bash需要完整的登錄流程,即/etc/profile(系統(tǒng)整體的設(shè)定)和~.bash_profile ~.bash_login ~/.profile(個人設(shè)定);

non-login shell:會讀取這個~/.bashrc配置文件

以下4點(diǎn)會取得login shell:

登錄系統(tǒng)時獲得的頂層shell,無論是通過本地終端登錄,還是通過網(wǎng)絡(luò)ssh登錄。這種情況下獲得的login shell是一個交互式shell。

在終端下使用--login選項(xiàng)調(diào)用bash,可以獲得一個交互式login shell。

在腳本中使用--login選項(xiàng)調(diào)用bash(比如在shell腳本第一行做如下指定:#!/bin/bash --login),此時得到一個非交互式的login shell。

使用"su -"切換到指定用戶時,獲得此用戶的login shell。如果不使用"-",則獲得non-login shell。

1. /etc/profile:若想所有用戶登錄系統(tǒng)時都要改變,就修改此文件,建議不修改。[root@www?~]#?cat?-n?/etc/profile?#共有80多行

1??#?/etc/profile

2

3??#?System?wide?environment?and?startup?programs,?for?login?setup

4??#?Functions?and?aliases?go?in?/etc/bashrc

5

6??#?It's?NOT?a?good?idea?to?change?this?file?unless?you?know?what?you

7??#?are?doing.?It's?much?better?to?create?a?custom.sh?shell?script?in

8??#?/etc/profile.d/?to?make?custom?changes?to?your?environment,?as?this

9??#?will?prevent?the?need?for?merging?in?future?updates.

…………

根據(jù)用戶設(shè)定PATH變量

…………

有PATH?USER?LOGNAME?MAIL?HOSTNAME?HISTSIZE?HISTCONTROL這些環(huán)境變量等信息;

此文件還會調(diào)用/etc/profile.d/*.sh,如for?i?in?/etc/profile.d/*.sh?;?do

if?[?-r?"$i"?];?then

if?[?"${-#*i}"?!=?"$-"?];?then

.?"$i"

else

.?"$i"?>/dev/null?2>&1

fi

fi

done

[root@www?~]#?ls?-l?/etc/profile.d/

總用量?44

-rw-r--r--.?1?root?root?1127?10月?17?2013?colorls.csh

-rw-r--r--.?1?root?root?1143?10月?17?2013?colorls.sh

-rw-r--r--.?1?root?root??192?8月??27?2013?glib2.csh

-rw-r--r--.?1?root?root??192?8月??27?2013?glib2.sh

-rw-r--r--.?1?root?root?1741?11月?23?2013?lang.csh

-rw-r--r--.?1?root?root?2706?11月?23?2013?lang.sh

-rw-r--r--.?1?root?root??122?2月???7?2007?less.csh

-rw-r--r--.?1?root?root??108?2月???7?2007?less.sh

-rw-r--r--.?1?root?root??105?12月?22?2016?vim.csh

-rw-r--r--.?1?root?root??269?12月?22?2016?vim.sh

-rw-r--r--.?1?root?root??169?5月??20?2009?which2.sh由lang.sh又去調(diào)用/etc/sysconfig/i18n來設(shè)置語系。

2.? 讀完/etc/profile后調(diào)用完其他文件。就是調(diào)用~/.bash_profile ~/.bash_login ~/.profile

只會讀取上面三個文件中的其中一個,默認(rèn)順序就是以上順序,

當(dāng)修改了整體配置文件或個人配置文件,需要使用source命令來讀取這些文件來生效。或者使用. 配置文件使配置文件生效

總結(jié)

以上是生活随笔為你收集整理的linux bash文件,linux之bash配置文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。