What is and Where is the .bashrc File in Linux?
The .bashrc
file is an important configuration file in Linux systems that controls the behavior and settings of the Bash shell, the default shell for most Linux distributions.
You may need to customize this file when making changes to your Bash shell such as changing the prompt, adding environment variables, adding functions or more.
In this tutorial, we will attempt to explain what is the role of this file and where you can find it in your Linux system.
Hidden Files in Linux
Before you can make any changes or attempt to locate the .bashrc
file in your Linux system, you need to know about hidden files.
In Linux, hidden files are any files and directories whose name are preceeded by a dot symbol in the name. By default, hidden files are not displayed in Linux file managers or when using the ls
comand unless using the -a
flag.
Linux File Managers Show Hidden Files
Therefore, to show the .bashrc
file in a file manager, you need to tell it to show hidden files. Check the steps of how to show hidden files for your manager in the steps below.
Nautilus (GNOME):
- Open the file manager (Nautilus).
- Press Ctrl+H to toggle the display of hidden files. Alternatively, click on the menu button (hamburger icon) at the top right, then select “Show Hidden Files.”
Nemo (Cinnamon):
- Open the file manager (Nemo).
- Press Ctrl+H to toggle the display of hidden files. Alternatively, click on the menu button (hamburger icon) at the top right, then select “Show Hidden Files.”
Dolphin (KDE):
- Open the file manager (Dolphin).
- Press Ctrl+H to toggle the display of hidden files. Alternatively, click on “View” in the menu bar, then check the “Show Hidden Files” option.
Thunar (Xfce):
- Open the file manager (Thunar).
- Click on “View” in the menu bar.
- Check the “Show Hidden Files” option.
PCManFM (LXDE):
- Open the file manager (PCManFM).
- Click on “View” in the menu bar.
- Check the “Show Hidden” option.
Caja (MATE):
- Open the file manager (Caja).
- Click on “View” in the menu bar.
- Check the “Show Hidden Files” option.
Where is the .bashrc File?
The .bashrc file is typically located in the user’s home directory. The home directory is represented by the tilde (~) symbol.
Hence, the absolute path to the .bashrc file is ~/.bashrc
.
Editing the .bashrc
To edit the .bashrc
file, open a terminal and use a text editor of your choice, such as nano
, vim
, or gedit
. For example, to edit the .bashrc file using nano, run the following command:
nano ~/.bashrc
This will open the .bashrc file in the nano text editor.
You can also edit the file using Graphical Interface using any Graphical text editor of your choice.
Applying Changes to the .bashrc File
Once you make modifications to the .bashrc
file, save the changes and exit the text editor.
To apply the changes, use the source
command as:
source ~/.bashrc
You can also run the .bashrc
file:
bash ~/.bashrc
Conclusion
The .bashrc file is a crucial configuration file in Linux that allows you to personalize the Bash shell environment. By understanding its purpose and location, as well as how to edit and apply changes, you can fully leverage the capabilities of the .bashrc
file to enhance your Linux experience.