Create Environment Variable

The best way to store login credentials and API tokens/secrets is by creating environment variables for them. This means they are variables in the Linux system and thus not present in any code that is shared on GitHub.

There are many ways to create environment variables, but my personal preference is to add them to the .bashrc file in our home directory. .bashrc does a lot of things, but it is a standard place to put customizations to our system – for example, custom variables.

View The End Of .bashrc File

tail ~/.bashrc
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

# added by Anaconda3 installer
export PATH="/home/chris/anaconda3/bin:$PATH"

alias lcl='ls -l'

Append Environment Variable To End Of .bashrc

echo 'APIKEY="cH4ris_1s_c000l"' >> ~/.bashrc

View The End Of .bashrc File

tail ~/.bashrc
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

# added by Anaconda3 installer
export PATH="/home/chris/anaconda3/bin:$PATH"

alias lcl='ls -l'
APIKEY="cH4ris_1s_c000l"

Reload .bashrc

source ~/.bashrc

View New Environment Variable

echo $APIKEY
cH4ris_1s_c000l