Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu bashrc file how to find what file is used?

How do I find which .bashrc file is loaded when shell is started? Are there any command that can tell me that?

Currently I think it is /root/.bashrc it is a Ubuntu server 10.04 LTS.

Is it userbased or?

like image 1000
Rails beginner Avatar asked Feb 16 '13 14:02

Rails beginner


2 Answers

Simply use echo. Put an expression into bashrc

echo "I am in $PWD/$0" or "I am in bashrc file".

With that you will see when logging on a printed message which will confirm you that process uses specific script file. Note - it is not wise to e.g. start a program from bashrc or bash_profile, because if program for some reason won't start or will have trouble to start, you won't be get into a shell.

like image 93
Piotr Wadas Avatar answered Sep 30 '22 15:09

Piotr Wadas


The command you seek is man bash, which tells you:

   When  bash is invoked as an interactive login shell, or as a non-inter-
   active shell with the --login option, it first reads and executes  com-
   mands  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.

and

   When an interactive shell that is not a login shell  is  started,  bash
   reads  and executes commands from ~/.bashrc, if that file exists.  This
   may be inhibited by using the --norc option.  The --rcfile file  option
   will  force  bash  to  read  and  execute commands from file instead of
   ~/.bashrc.
like image 35
William Pursell Avatar answered Sep 30 '22 14:09

William Pursell