shell型別與配置檔案

2021-07-06 09:52:24 字數 668 閱讀 8980

站在使用者登入的角度來說,shell的型別

登入式shell:

非登入式shell:

bash的配置檔案

全域性配置

/etc/profile, /etc/profile.d/*.sh, /etc/bashrc

個人配置

~/.bash_profile, ~/.bashrc

不同型別配置檔案用途:   

profile類的檔案作用:

設定環境變數

執行命令或指令碼

bashrc類的檔案作用:

設定本地變數

定義命令別名

配置檔案讀取

登入式shell如何讀取配置檔案?

/etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc

非登入式shell如何配置檔案?

~/.bashrc --> /etc/basrc --> /etc/profile.d/*.sh

就近原則:當全域性配置檔案和使用者自定義配置檔案產生衝突時,系統以使用者自定義配置檔案的配置為準。

Shell配置檔案與Shell Script

1.etc profie 這是系統中最主要的shell配置檔案,也是系統登入時系統最先檢查的檔案。系統最主要的環境變數都定義在此。在檔案的最後,它會檢查並執行 etc profile.d sh的script。2.bash profile 這個檔案是每位使用者的bash環境配置檔案,它存在於使用者的主...

shell指令碼讀取配置檔案

在shell指令碼中讀取配置檔案使用 cat grep,awk和sed 比如在 eaxmple.ini中有 ftp url 127.0.0.1 223 ftp user admin ftp password ftp 則在shell指令碼中讀取配置 ftp url cat eaxmple.ini gr...

shell實現配置檔案解析

需求 解析乙個特定格式的檔案 這個檔案可以成為乙個配置檔案 逐行讀取,並列印出來。方案 while實現讀取,然後用awk進行讀取相應的值。第一步 用while讀取檔案。while read filedo done config.txt 這裡file是乙個變數,代表讀的那一行,shell是弱資料型別語...