当前位置:网站首页>Bashrc and profile
Bashrc and profile
2022-07-07 14:14:00 【sinat_ thirty-six million seven hundred and eighty-nine thousan】
Reading guide : Interactive shell And non interactive shell; login shell and non-login shell
Interactive mode is shell Waiting for your input , And execute the order you submitted . This pattern is called interactive because shell Interact with users . This pattern is also familiar to most users : Sign in 、 Execute some orders 、 Sign off . When you sign back ,shell It's over . shell It can also run in another mode :
Non interactive mode . In this mode ,shell Don't interact with you , Instead, read the commands stored in the file , And execute them . When it reads to the end of the file ,shell It's over .
One 、bashrc And profile Are used to save the user's environment information . Let's go through each of these :
/etc/profile( overall situation , For interactive login shell): This file sets the environment information for each user of the system , When the first user logs in , The document is executed . And from /etc/profile.d Directory of configuration files shell Set up .
When the /etc/profile If there is any modification, you must restart the modification to take effect , This change takes effect for every user .
/etc/pro.d:.d Presentation directory , The directory contains some startup scripts required by the application , It includes color 、 Language 、less、vim And which Some additional settings of the command . The reason why these script files can be executed automatically , Because in /etc/profile Use one for Loop statements to call these scripts . These script files are used to set some variables and run some initialization processes .
# for example :
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then # Judge /etc/profile.d Is it a directory
for i in /etc/profile.d/*.sh; do # If it's a directory , Go to this directory , Take out each shell Program
if [ -r $i ]; then # If it's time to shell It can be executed
. $i # Then execute it
fi
done
unset i
fi
/etc/bashrc( overall situation , For non interactive non-loginshell): For each run bash shell Of users executing this file . When bash shell When opened , The file is read ( There are some linux In version /etc There is no more bashrc file ).
If you want to use it for all bash Users who modify a configuration and open it later bash You can modify this file if it takes effect , You don't need to restart to modify this file , Reopen a bash Effective .
~/.bash_profile( Interactive 、login Way in bash function ): Each user can use this file to input the shell Information , When the user logs in , The file is only executed once ! By default , He sets some environment variables , Execute the user's .bashrc file .
This file is similar to /etc/profile, It also needs to be restarted to take effect ,/etc/profile Effective for all users ,~/.bash_profile Only valid for the current user .
~/.bashrc( Interactive non-login Way in bash function ): This file contains... For a specific user bash shell Of bash Information , When the user logs in and every time the new shell when , The file is read . Each user has one .bashrc file .
~/.bash_logout: Every time you exit the system ( sign out bash shell) when , Execute the document .
Two 、 similarities and differences :
1、bashrc It will run automatically after the system starts .profile Only after the user logs in .
2、/etc/profile Variable set in etc ( overall situation ) Can work for any user , and ~/.bashrc Variable set in etc ( Local ) Can only inherit /etc/profile The variables in the , They are " Father and son " Relationship .
3、 After setting , It can be used source bashrc The command to update bashrc, You can also use source profile The command to update profile.
3、 ... and 、 Get a... When logging in shell Process time , There are three steps to read the environment profile
1、 The global environment variable profile is read in first /etc/profile, Then read the additional set document according to its content , Such as :/etc/profile.d and /etc/inputrc
2、 Then according to different user accounts , Go to their home directory to read ~/.bash_profile, If this can't be read, read ~/.bash_login, This can't be read before ~/.profile, These three document settings are basically the same , Read has priority
3、 Then read according to the user account ~/.bashrc. as for ~/.profile And ~/.bashrc All of them have the function of personalized customization .
~/.profile You can set the exclusive path of this user , Environmental variables, etc , It can only be executed once when logging in
~/.bashrc It is also a user specific setting document , You can set the path , Command alias , Every time shell script It will be used once for the execution of
边栏推荐
- Assign a dynamic value to the background color of DataGrid through ivalueconverter
- [AI practice] Application xgboost Xgbregressor builds air quality prediction model (II)
- 接口自动化测试-接口间数据依赖问题解决
- IP address home location query
- 高等數學---第八章多元函數微分學1
- Excuse me, I have three partitions in Kafka, and the flinksql task has written the join operation. How can I give the join operation alone
- . Net core about redis pipeline and transactions
- Cesium 已知一点经纬度和距离求另一个点的经纬度
- gvim【三】【_vimrc配置】
- 2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
猜你喜欢
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
VSCode 配置使用 PyLint 语法检查器
Excerpt from "misogyny: female disgust in Japan"
Introduction to sakt method
Use day JS let time (displayed as minutes, hours, days, months, and so on)
TPG x AIDU | AI leading talent recruitment plan in progress!
Reverse non return to zero code, Manchester code and differential Manchester code of common digital signal coding
566. Reshaping the matrix
高等数学---第八章多元函数微分学1
Build a secure and trusted computing platform based on Kunpeng's native security
随机推荐
Regular expression integer positive integer some basic expressions
Horizontal of libsgm_ path_ Interpretation of aggregation program
供应链供需预估-[时间序列]
AI人才培育新思路,这场直播有你关心的
Excusez - moi, l'exécution a été réussie lors de l'utilisation des données de puits SQL Flink à Kafka, mais il n'y a pas de nombre dans Kafka
Is the compass stock software reliable? Is it safe to trade stocks?
call undefined function openssl_cipher_iv_length
mysql ”Invalid use of null value“ 解决方法
股票开户首选,炒股交易开户佣金最低网上开户安全吗
【立体匹配论文阅读】【三】INTS
Cesium 已知一点经纬度和距离求另一个点的经纬度
Is the spare money in your hand better to fry stocks or buy financial products?
交换机和路由器的异同
Introduction to sakt method
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (II)
Huawei image address
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
搜索引擎接口
FC连接数据库,一定要使用自定义域名才能在外面访问吗?
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou