Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

At my company there are system-wide bashrc files like /etc/bashrc and so on.

Inside, they source more and more files. It's very confusing (I noticed my "ls" is aliased with a bunch of flags to ls that I don't want).

I want to for my ~/.bashrc clear the effects of all bashrcs.

Is there something like that in bash? Just to clear all aliases, functions, etc, defined in system-wide files.

share|improve this question
add comment

1 Answer 1

The easiest way would be to add this line to your ~/.bashrc :

unalias -a

As far as I know, there is no equivalent for clearing all functions. You can, however, clear them one by one using

unset -f function_name

The following two bash options are also relevant:

  --rcfile file
          Execute  commands  from file instead of the system wide
          initialization file /etc/bash.bashrc and  the  standard
          personal  initialization file ~/.bashrc if the shell is
          interactive (see INVOCATION below).

  --norc Do  not read and execute the system wide initialization
          file /etc/bash.bashrc and the  personal  initialization
          file  ~/.bashrc  if  the  shell  is  interactive.  This
          option is on by default if the shell is invoked as sh.

So, you could set bash to be an alias for bash --norc:

    alias bash='/bin/bash --norc'

That way, every time you manually launch bash a new shell will be started with no initialization files. You would then need to manually source your .bashrc.

I thought you could combine the --norc and --rcfile options to read your ~/.bashrc only but could not get it to work.

share|improve this answer
add comment

Your Answer

 
discard

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.