In Linux, bashrc is a script file. This script file execute when the terminal is open. It is responsible for the terminal operations.
What is .bashrc file? | How to use it? | with Examples
![]() |
.bashrc file in Linux |
Hello, guys welcome to the next session on Linux command line tutorial.
In this session, I'm going to talk about ".bashrc" file in Linux.
What is ".bashrc" file?
The ".bashrc" file is a script that is executed whenever a "New terminal" session is started in interactive mode.
Location of .bashrc file
First of all, You open your terminal and just check whether you are in your home directory or not.
By default, you are already in the home directory. Whenever you open your terminal.
![]() |
.bashrc file |
In here you can just write "ls -a" for listing all "hidden files" and you will be able to see there is a file called ".bashrc".
This is the file which is responsible for whenever you open a new terminal this file is executed.
This is a kind of a "script" that is executed first whenever you open a new terminal session.
Open .bashrc file
Let's go inside this ".bashrc" file. So you can use "nano" command to display the content of this ".bashrc" file.
![]() |
edit ".bashrc" file using nano text editor |
$nano .bashrc
Just write "nano .bashrc" and you can go inside this file and you can see the content of this file.
What is the purpose? How to use it?
This "script" is executed whenever you open a new terminal. So whatever you add to the script it will be executed first whenever you open a new terminal session.
![]() |
Example script |
- Let's add some "welcome text".
So you just need to go the end of this file.
For example, echo "Hii, welcome to Linux" and close the editor.
Now I'm going to open a new terminal session.
![]() |
New terminal |
The text I have written in the ".bashrc" file is executed.
So using this we know that this ".bashrc" file is called first because it's executing our "echo" command also and then your normal terminal operation.
Conclusion
So in this way you can customize your ".bashrc" file mostly we use this .bashrc file for a number of things.
For example, You install Java you need to set up the Java home environment variable and this can be done using this ".bashrc" file.
I hope you understood the basic concept of ".bashrc" file.
I hope you enjoyed this tutorial please rate comment and bye.
HAVE A NICE DAY💖
Related,