欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在ubuntu中.profile 和.bashrc的加载区别

程序员文章站 2022-05-19 22:51:53
...
总之,profile不只是bash,在启动加载
bashrc是bash在,起bash session加载

.bashrc is for Bash only, while .profile is used by other shells as well.

Another important difference is that .profile is used at the time when you log in, be it on a terminal, or into your desktop. So settings in there will apply always when youa re logged in. Bashrc on the other hand is executed each time you open a Bash session, for example every time you open a terminal.

Here's an example, I want to add ~/bin to my path, so that I can run programs in that directory without having to type the full apth to them. Since I want that to wosk all the time, even for desktop applications, I need to define that in the .profile file. (doing it in .-bashrc would work for terminal only)

On the other hand I also want to get a fortune every time I open a terminal. So I need to add the comamnd into my .bashrc. (doing it in .profile wouldn't have any noticeable effect when using terminal emulators, since the file wold execute when I log into my desktop, not for each terminal I open).
相关标签: ubuntu bash