• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Difference between etc/bashrc and home/username/.bashrc?  RSS feed

 
Ranch Hand
Posts: 1313
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that there are two kind of bashrc files in the linux folder stucture. one is located in etc/bashrc. Other one is located in Home/username/.bashrc.

1) What is the difference purpose of these two files ?
2) are both using for setting envirnment variables?
 
Marshal
Posts: 64483
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you open both those files with a text editor and have a look at them.
The file in /etc will run whenever any user opens a terminal with bash, but that in your home directory will only run when you open a terminal. Other users will have other .bashrc files in their home folders. I don't know which runs first.
 
sam liya
Ranch Hand
Posts: 1313
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added echo command in both files. Then i open new terminal it shows both echo commands. first shows the etc echo command and then shows the other echo commands. that means bashrc in the etc folder runs 1st.
 
Campbell Ritchie
Marshal
Posts: 64483
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sam liya wrote:. . . bashrc in the etc folder runs 1st.

That is what I would have expected, but I wasn't sure.
 
Sheriff
Posts: 21742
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Summarizing: /etc/bashrc contains system defaults for all users, and ~/.bashrc contains user-specific additions. The latter is optional, if it does not exist then only the defaults are used.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!