1

Is there a way to change the file that my terminal loads so that it never opens or executes my .bash_profile? But still executes a different file in a different directory?

Thanks!

3 Answers 3

3

The simplest thing to do would be to change the contents for your .bash_profile file to contain only:

. /path/to/other/file
Sign up to request clarification or add additional context in comments.

1 Comment

I am looking for a way for the bypass the bash_profile so that no code could be inserted into the file.
2

You can inhibit reading any default startup file with --noprofile --norc. Additionally you can give bash the location of one startup file using --rcfile file. See man bash for details about these options.

In the file provided by --rcfile you can load the standard files in any way you wish.

But the consequences are, that you have to emulate quite a bit of code to get the behaviour of that shell approximately right in regard to system settings, aliases, completions, standard functions, ... You must be very desperate to go that road.

Comments

1

No - you can pass --noprofile to bash to inhibit reading the .bash_profile file completely, but you can't override the location of the file bash looks for.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

1 Comment

I was looking at the /etc/profile and it looks like a file link, there is no way of changing this path?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.