Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed that you can prevent reading /etc/profile by running

bash --noprofile

However this also stops ~/.bash_profile from being read. Can Bash be invoked in such a way as to read ~/.bash_profile but not /etc/profile?

share|improve this question
up vote 1 down vote accepted

Try the options --noprofile and --rcfile file_name where file_name is the config file you want read, e.g:

bash --noprofile --rcfile ~/.bash_profile

Well... somebody didn't like this answer, but it appears to be exactly what was desired:

--noprofile causes all normal rc files to not be read.
--rcfile <some file> causes the specified file to be read instead. This can certainly be the user's .bash_profile as requested.

share|improve this answer

You can simply do add in ~/.bashrc file

if [ -f ~/.bash_profile ]; then
        . ~/.bash_profile
share|improve this answer

The login shell will always read /etc/profile, which allows the system admin to set environment variables and paths for all users.

If you are the only user and this is your system you are free to edit or remove /etc/profile if you wish.

share|improve this answer
No... --noprofile from the manpage: "Do no read either the system-wide startup file /etc/profile or any of the personal initialization files ..." – SuperMagic Feb 18 '13 at 22:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.