这个必定要理解登陆式shell和非登陆式shell的区别,前者是彻底切换用户,后者是不彻底,就算切换过来了,你pwd时家目录仍是以前的家目录,因此shell
登陆式顺序为:/etc/bashrc---/etc/profile.d/*.sh----~/.bash_profile---~/.bashrc_profile----~/.bashrc-----/etc/bashrctomcat
非登陆式:~/.bashrc-----/etc/bashrc-/etc/profile.d/*.shbash
/etc/profile:
该文件登陆操做系统时,为每一个用户设置环境信息,当用户第一次登陆时,该文件被执行。也就是说这个文件对当前每一个shell都有效,若是此时su 其余用户没有- ,则切过去的用户没法使用你alias的别名,应为是他是登录时就产生的,用于获取系统的环境信息。 less
/etc/bashrc:为每个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。也就是说,当用户shell执行了bash时,就运行这个文件,不管你su切换其余用户加-仍是不加-alias都有效。ide
三、`/.bashrc该文件存储的是专属于我的bash shell的信息,当登陆时以及每次打开一个新的shell时,执行这个文件。在这个文件里能够自定义用户专属的我的信息。this
一、环境变量配置缘由idea
环境变量:指定一个目录,运行软件或程序的时候,相关程序会按照目录寻找相关文件spa
缘由:使你能够在非安装目录运行软件操作系统
二、环境变量的设置方法.net
(1) 控制台,仅临时有效,仅针对于当前shell
须要给某个用户权限只须要在其我的主目录想修改便可。修改方法相似于/etc/profile文件
三、~/.bashrc、~/.bash_profile、~/.bash.profile和/etc/bashrc和/etc/profile的区别
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.
②/ etc / bashrc:
为每个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。也就是说,当用户shell执行了bash时,运 行这个文件。
1 # /etc/bashrc 2 3 # System wide functions and aliases 4 # Environment stuff goes in /etc/profile 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.
③〜/ .bashrc 该文件存储的是专属于我的bash shell的信息,当登陆时以及每次打开一个新的shell时,执行这个文件。在这个文件里能够自定义用户专属的我的信息。
④~/.bash_profile:每一个用户均可使用该文件输入专用于本身使用的shell信息,当用户登陆时,该 文件仅仅执行一次!默认状况下,他设置一些环境变量,执行用户的.bashrc文件.
一、在登陆时,操做系统定制用户环境时使用的第一个文件就是 /etc/profile ,此文件为系统的每一个用户设置环境信息,当用户第一次登陆时,该文件被执行。
二、在登陆时操做系统使用的第二个文件是 /etc/environment ,系统在读取你本身的profile 前,设置环境文件的环境变量。
三、在登陆时用到的第三个文件是.profile文件,每一个用户均可使用该文件输入专用于本身使用的shell信息,,该 文件仅仅执行一次!默认状况下,他设置一些环境变量,执行用户的.bashrc文件。/etc/bashrc:为每个运行bash shell的用户执行此文件。当bash shell 被打开时,该文件被读取。
cankao:https://blog.csdn.net/jirryzhang/article/details/70833544