Linux .bash_profile File

Linux bash is a shell provided by most of the Linux distributions. The bash is the easiest to learn and use the shell. The bash shell provides a lot of features that can be configured by using bash configuration files like /etc/profile , ~/.bash_profile , ~/.bash_login etc. The .bash_profile file is located in the current user home directory as a hidden file. In some distributions may use the ~/.bashrc according to the .bash_profile file.

Bash Configuration Files

Bash provides different configuration files. The /etc/profile file is used by all users in a Linux system and first, these configurations are applied to the bash shell. And the .bash_profile is located under every user home directory where every user may have different bash configurations. This configuration file overwrites over /etc/profile configuration.

Create .bash_profile File

By default the .bash_profile is not created by the most of the Linux distirubtions. Actually the .bash_profile is a normal text file which contains bash configuration like regular bash commands. We can create .bash_profile file like below.

$ touch ~/.bash_profile

Previous command only creates the .bash_profile file but do not opens it to make some changes and configuration. Alternatively following command can be used to create if not exist and edit the .bash_profile file.

$ nano ~/.bash_profile

Configure .bash_profile File

Bash provides a lot of features even a programming language. All of them can be configured via a bash shell. Also, the .bash_profile file is used to configured newly opened bash shells or terminals. For example, the command prompt is set with the PS1 environment variable and the bash shell command prompt can be changed by setting a new value for the PS1 environment variable in the .bash_profile file.

export PS1 = "$ "
READ  "Read-only File System" Error and Solutions

Leave a Comment