
The Bash profile files are used to define environment variables, such as the directories in the $PATH variable and the users default editor, such as vi or nano in the $EDITOR variable. For example, a very simply Bash profile file may contain something like this.
export EDITOR=/usr/bin/vi
export PATH=$PATH:/usr/local/bin
User personal Bash profile file
Each user will have their own personal Bash profile file, like this.
- /root/.bash_profile
- /home/john.doe/.bash_profile
- /home/jane.doe/.bash_profile
The users personal Bash profile file will take precedence over the global, system wide Bash profile file.
Global Bash profile file
On a Red Hat distribution, the global Bash profile file is /etc/profile This file reads scripts in the /etc/profile.d directory. For example, the following script could be used to set the $EDITOR variable to use the vi editor.
- /etc/profile.d/vi-default-editor.sh
The vi-default-edtior.sh script could contain something like this.
#!/bin/sh
if [ -z "$EDITOR" ]; then
export EDITOR=/usr/bin/vi
fi
Did you find this article helpful?
If so, consider buying me a coffee over at