Linux is a free UNIX-like operating system that is useful for developers and creators worldwide. There are numerous Linux distributions that you can use depending on your needs and wants. However, as much as these distros are popular, Linux is not easy to use and requires having some technical skills.
Now, when we talk about the term technical in Linux, there are many things like Linux .bashrc file, bash profile, and more. However, many people are unaware of these terms. Hence, today we will discuss all that is .bashrc file in Linux in detail.
What is the .bashrc file in Linux?
For those of you who do not know, the .bashrc file is a file you must first understand about a shell terminal. So, let us begin. A shell in any operating system is like an interpreter that takes the input of any users and runs them to operate. The input given by the user is in text.
Now, talking about Linux .bashrc file, so basically, it is a script that is executed when you log in to your Linux-based operating system. Without it, you cannot start your bash shell in your Linux-based operating system. This shell script consists of numerous configurations about how you can use the Linux shell.
These configurations can help you change the shell’s environment based on your preferences. In addition, you can also start the .bashrc file from the beginning. However, to do this, you need to know the right key combination, which is Ctrl+Alt+T. Moreover, you can also initiate a .bashrc file from the beginning by opening a new terminal tab.
What is the .bashrc file location in Linux?
Bashrc file is a hidden file, and finding it requires than just single command, like ls. However, the .bashrc file resides inside the home directory of your local Linux-based operating system. Once the .bashrc file is executed, it reads all the information and executes bash scripts.
In short, you cannot operate your Linux operating system such as Ubuntu without a Bashrc Ubuntu file. Hence, to find the bashrc file location in Linux, make sure to know your home directory.
Bash profiles. .bashrc file:
Other than the bash rc file, there is a bash_profile as well. While both of them have the name “bash” attached to them, they are pretty different than each other. The primary difference between these two is that bash_profile is executed for login shells.
It means when you log in to your Linux system by putting your login credentials via the built-in console, bash_profile is executed.
On the other hand, the bash rc file is for non-login shells, which means it is not executed when a bash acts as a login shell. To put it in simpler words, the bash rc file is executed when you open a new terminal tab or start a new bash instance in the shell.
How to start bashrc in Linux:
There are numerous Linux shells, including DASH and BASH. However, whatever Linux shell you use, you can get access to the bash rc file such as Bashrc Ubuntu that resides in your Linux’s home directory. To start a bash rc file in Linux, makes sure to:
- Open a new terminal window by pressing CTRL, ALT, and T all at once
- Then write “find / – name .bashrc
- After writing the command on the console, you would see the following results:
- /etc./skel/.bashrc – When new users are created on a specific Linux system, this file gets copied into their home folder and is their bash rc file by default.
- /home/John/.bashrc – This bashrc file is executed when a user called John starts the shell.
- /root/.bashrc – This bashrc root file is executed when someone opens the shell in the root directory.
Make sure to be careful when writing these commands on the shell, as wrong commands can get you in trouble.
Source command in Linux bashrc:
The source command in Linux bashrc tends to evaluate the bashrc file passed as the argument in the context of the current execution. Source command is also used to refresh the current shell environment directly from the terminal.
To refresh the current shell environment using source type in the following:
$ Source ~/.bashrc, or $ . ~/.bashrc
You can also use the source command to import a script function. To do this type:
source./script, However, there are some steps before it, so make sure to follow them as well.
You can also read variables from the bashrc file using the command source. /variables on the shell. We hope you get this basic touch with linux bashrc here.
Aliases and functions:
Creating aliases for long commands helps you save time and effort and are often defined as shortcuts. For example, you can use the command ls to view all the hidden content of your directory. There are numerous aliases and functions is bash rc. Some of the most popular ones are:
- ll, which is used to view all the necessary and hidden information of the files in the home directory.
- You can also create your custom temporary aliases by typing the word “alias” followed by the name you wish to use for executing a command. After the name, put the = sign and quote the command you want to alias.
- You can also use type the command $alias to know about the defined aliases on your profile.
You can also create functions in bashrc to reduce redundancy by using the commands $vi .bashrc and source .bashrc.
How to stop a running Bash script or command?
To stop a running bash script or command, press CTRL+C, or you can also use CTRL+D to close the shell. You can also press CTRL+Z if CTRL+C does not seem to work for you. In some Linux distros, CTRL+C does the job of terminating a bash script. However, in some, you need to get the PID of the script and send SIGKILL to kill the bash command or script.
How to edit bashrc files:
You can edit your Linux bashrc files by the source and nano command. Type nano ~/ .bashrc or source ~/ .bashrc to edit Linux .bashrc files.
Does Windows support .bashrc at all like Mac and Linux?
No, Windows does not support .bashrc at all like Mac and Linux operating systems.
Is Bashrc Ubuntu different?
No, however, certain commands can be.
Is choosing a Linux VPS hosting good for Linux?
You should choose Linux VPS hosting services to make sure that your Linux distro continues to function well.