The .bashrc file enables customization of the user’s own environment. The file is stored in a user’s home directory. Because the .bashrc file is unique to each user, it can be configured to a user’s own specific needs or preferences.
A good example of the use of the .bashrc file is the use of aliases. Users can specify their own abbreviated commands without impacting the experience of any other user on the system. Another common configuration within .bashrc is environment variables. Users can also use the file to customize the command prompt to provide the information they want.
The /etc/skel/.bashrc is usually used for storing alias for various commands. This can be seen by looking at /etc/skel/.bashrc:
# cat /etc/skel/.bashrc # colored GCC warnings and errors #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' # some more ls aliases alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'
Example Configurations
Other than creating aliases, the .bashrc file is often configured to set default directory and file permissions for the user. Also, the default command prompt can be altered to provide more information. Most distributions place the user name, system hostname, and current directory in the prompt, but that can be changed.
Any addition done in ~/.bashrc will be reflected only to the current user’s bash shell. We can see that the .bashrc file also checks whether the etc/bashrc file is available. If available, that gets executed too. The /etc/bashrc file contains configuration applied to a bash shell for all users—that is, systemwide. Sysadmin can modify the /etc/bashrc file if any configuration needs to be applied to all users’ bash shells.
To apply modified settings, open a new bash shell. To apply a new .bashrc in the same bash shell, you can source into a new ~/.bashrc file:
$ source ~/.bashrc