How To Create & Configure Shell .Bash_Profile & .Bashrc & Path Variables For Windows, Mac & Linux

Follow Us on Social Media

 How To Create & Configure Shell .Bash_Profile & .Bashrc & Path Variables For Windows, Mac & Linux

How To Create & Configure Shell .Bash_Profile & .Bashrc & Path Variables For Windows, Mac & Linux

As a programming language, the shell can accept and run commands. All shell configuration files are usually stored within the .bash_profile for Windows and Mac. This is also true for Linux for login sessions. For login sessions Linux makes use of the .bashrc file.

For users on Mac and Linux, these configurations files come with the OS. 

The .bash_profile and .bashrc config files are not available for Windows users using Git Bash.

This config. file is also the location where the path variables are stored, so you don't always need to enter these variables at every session when you run the shell.

To create the .bash_profile for Windows, follow these steps:

Navigate to the home directory using cd or cd ~


Create a .bashrc file using  touch .bashrc

Edit the just created .bashrc file using vim bashrc

Save and close the file with the command :wq then press enter.

Close/Restart Git Bash.

Git Bash will create a .bash_profile for you when you open it next.

Since for non-login sessions, the Linux server makes use of .bashrc, the configuration information to add to the .bash_profile so Linux runs the bahrc file when needed is:

if [-f ~/.bashrc]; then
source ~/.bashrc
fi

This tells linux to run the .bashrc file if it exists.


To add the path to the .bash_profile so its always available when load start up the shell, add the path like this:

PATH=$PATH:/users/user/bin.

This should be replaced with the actual location of your binary files.

No comments



Powered by Blogger.