标签:profile shell 配置文件 区分 etc 生效 login 环境变量 bash
长求总:全局变量在/etc目录下,用户自定义在~/目录下,仅针对bash shell就找%bashrc%类文件
1. /etc/profile
对所有用户、所有shell均有效
登陆操作系统后,该文件被读取,从/etc/profile.d的配置文件中搜集shell相关设置
生效方式:source命令或重启操作系统
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
2. /etc/.bashrc 或 /etc/bash.bashrc
对所有运行bash shell的用户生效
打开bash shell时,该文件被读取
生效方式:重启bash shell
# System-wide .bashrc file for interactive bash(1) shells. # To enable the settings / commands in this file for login shells as well, # this file has to be sourced in /etc/profile.
3.~/.bash_profile >> ~/.bash_login >> ~/.profile
对当前用户生效
用户登陆操作系统后,根据优先级次序读取该用户的文件
生效方式:source命令或重启操作系统
# ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists.
4.~/.bashrc
对当前运行bash shell的用户生效
打开bash shell时,该用户的文件被读取(一般在~/.bash_profile之后)
生效方式:重启bash shell
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) for examples
5.~/.bash_logout
对当前关闭bash shell的用户生效
关闭bash shell时,该用户的文件被读取
生效方式:重启bash shell
# ~/.bash_logout: executed by bash(1) when login shell exits.
标签:profile,shell,配置文件,区分,etc,生效,login,环境变量,bash 来源: https://www.cnblogs.com/xmalll/p/15424885.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。