FreeKB - Linux Files Understanding the BASH and Profile files
Linux Files - Understanding the BASH and Profile files

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

 

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 46590 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |