unset .bashrc

Could someone please tell me how to unset your .bashrc? I have tried all of these. I can't find anything useful from google.

unset -f .bashrc
unset .bashrc

I'm not sure what you're trying to do.

The .bashrc is typically a file that is sourced during login. It has commands in it that are interpreted by the shell. In an environment I'm looking at at the moment, it's actually called by my .bash_profile, but it might also be set in /etc/profile or somewhere in /etc/profile.d.

What exactly do you want to undo or reverse in your .bashrc?

Yes. I want to undo the changes from my .bashrc.

Not really following.

You want to not execute your .bashrc?

In my .bash_profile, I have this:

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

If I wanted not to execute the .bashrc, I would change that to:

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
       : . ~/.bashrc
fi

or otherwise comment those lines out, or remove them.

Sometimes my changes from my .bashrc get annoying so sometimes I want to undo them. I would prefer not to have to log out to do this.

Will a new shell do?

user@wherever ~ $ bash --noprofile --norc
bash-4.1$ exit
user@wherever ~ $

You could even have it replace the current shell with exec bash --noprofile --norc .

Or if you just want it to reread your config file, exec bash .

1 Like

Still confused, I can only imagine that when you set something in your terminal that you don't want or didn't mean, you would like to "undo" that?

I don't really know what .bashrc has to do with this, or why it would suddenly change, reload itself, and start annoying you, so if you could post specific examples of what you mean, that would be dandy :slight_smile:

I think he means he has lots of aliases, functions etc. in his bashrc that he'd occasionally like to bypass.

2 Likes

Thank you. I like this one :).

exec bash

It is nice at times to have warnings. At other times when you are using these commands all of the time they get very annoying.

alias rm='rm -i'
alias mv='mv -i' 
alias cp='cp -i' 

---------- Post updated at 02:40 PM ---------- Previous update was at 02:36 PM ----------

Yes :). These 3 to be exact. Thank you for clarifying. Not good at explaining myself sometimes :(.

alias rm='rm -i'
alias mv='mv -i' 
alias cp='cp -i' 
1 Like

I agree that can be really annoying!

For that, you could unalias cp, etc.

Or bypass the alias with a back-slash:

\cp ...