Ubuntu bashrc file how to find what file is used?
11,959
Solution 1
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.
Solution 2
From here it would seem that your ~/.bashrc
is run unless you are logging in as root, as /root/
is root's home.
Solution 3
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.
Comments
-
Rails beginner over 1 year
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?
-
Rails beginner about 11 yearsOk, so if I am logged in as "someuser" is it using the .bashrc in /home/someuser/.bashrc what about the .bashrc_profile?
-
Piotr Wadas about 11 yearsTypically various files are used on startup of the shell if they exist. depending where you put your statement, you may find out that /etc/bashrc is used, /etc/bash/rcfile, /etc/profile, /etc/bash_completion.d/someother file, ~/.bashrc, ~/.profile, ~/.bash_profile etc. "root" user usually has ~/.profile while common user ~/.bash_profile