Where is .bashrc file found in Linux?
The only ones that bash looks at by default are in the user's home directory, yes. There is also typically a single source for them in Linux -- /etc/skel. The user's home directory does not need to be under /home, though.
I see you've edited your question to ask where your .bash_login and .bash_profile files are. Based on the #
prompt, I'm going to assume you're running this as root. In that case, your files are
/root/.bash_history
/root/.bashrc
See my original answer above regarding a user's home directory -- it's not always /home; in this case, root's home directory is /root
.
According to 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.
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
There is also /etc/bashrc
(/etc/bash.bashrc
in Debian-based Linux) which contains System wide functions and aliases
. By default, this is set, even for non-interactive, non-login shells.
EDIT:
The tilde
in the paths indicates the home directory
of the currently logged in user. Bash is only able to use one of ~/.bash_profile, ~/.bash_login, or ~/.profile
(per currently logged in user), in that order, for reading and executing commands. (Debian-based operating systems typically do not have ~/.bash_profile or ~/.bash_login.
They use the file ~/.profile
. This file explains that it will be read and used unless ~/.bash_profile or ~/.bash_login
are created.
#~/.profile: executed by the command interpreter for login shells.
#This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
exists.
Your bashrc
file's location is distro-dependent... Here is a basic list for the system bashrc
:
/etc/bashrc
(Redhat, Fedora, etc)
/etc/bash.bashrc
(Debian, Ubuntu, Linux Mint, Backtrack, Kali etc)
/etc/bash.bashrc.local
(Suse, OpenSuse, etc)
Then there is the private single-user bashrc
, which, for the most part is stored in ~/.bashrc
for basically every distro... If you do not have one of the distros listed, or have a special system, you can always look up bashrc
location on google for that distro or system...
Regards,
Interesting...