This question already has an answer here:

I am adding commands to $HOME/.bash_profile file


export ANDROID_HOME=/home/harsh/SDK


Now I have to run source $HOME/.bash_profile when my system boot every time. Is there any other option to permanent set these paths?

Problem: It's annoying to run this commands again and again when my system boot. Is there a way when I start my system and don't need to add this commands again?

marked as duplicate by roaima, Rui F Ribeiro, schily, meuh, Jesse_b Jun 6 '18 at 16:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Bash should read ~/.bash_profile on startup if it's started as a login shell, so it's not really just "a file". Now, the question is, how do you start Bash, if the login shell startup files don't take effect? In what sort of an environment? – ilkkachu Jun 6 '18 at 6:30
  • 1
    What is the file actually called, and which shell are you using? You are hopefully aware that various filenames on UNIX-ish systems are "magic" so it really does make a difference. – Philip Kendall Jun 6 '18 at 6:31
  • So I have to move that commands to .bashrc ? and link to .bash_login – Harsh Bhavsar Jun 6 '18 at 6:35
  • 3
    Please just edit your question to explain: 1) what you're trying to achieve 2) precisely what you've tried so far (not hiding details like which filename) 3) what's happening. Stop making random guesses as to what you should do until you've explained the issue or we can't really help. – Philip Kendall Jun 6 '18 at 6:41

You have to add entries to ".bashrc" file to create persistent environment variables for a user. Please see this for the detailed explanation.

  • 2
    Using .bash_profile should work too, provided that 1) the shell is a login shell, or 2) .bash_profile is sourced by .bashrc. In fact, I'd argue that .bash_profile is the correct place for setting up one's environment, while .bashrc is for things specifically related to interactive shell sessions (such as setting one's prompt, displaying a calendar or uptime etc.). – Kusalananda Jun 6 '18 at 6:40
  • 1
    This is at best misleading and at worst actively wrong. There are plenty more config files than ~/.bashrc and /etc/profile. – Philip Kendall Jun 6 '18 at 6:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.