I changed my “HOME” variable and now cannot find “~/.bash_profile” to change it back

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I was messing around with environment variables on my Mac, trying to learn how to use them and I used the command nano ~/.bash_profile where I then added the line HOME=/Users/MyCompName/Desktop to update my home variable.



This change worked and can be seen when I use printenv to view all environment variables but when I went to change HOME back I couldn't seem to find ~/.bash_profile anymore. Where did it go?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I was messing around with environment variables on my Mac, trying to learn how to use them and I used the command nano ~/.bash_profile where I then added the line HOME=/Users/MyCompName/Desktop to update my home variable.



    This change worked and can be seen when I use printenv to view all environment variables but when I went to change HOME back I couldn't seem to find ~/.bash_profile anymore. Where did it go?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I was messing around with environment variables on my Mac, trying to learn how to use them and I used the command nano ~/.bash_profile where I then added the line HOME=/Users/MyCompName/Desktop to update my home variable.



      This change worked and can be seen when I use printenv to view all environment variables but when I went to change HOME back I couldn't seem to find ~/.bash_profile anymore. Where did it go?










      share|improve this question













      I was messing around with environment variables on my Mac, trying to learn how to use them and I used the command nano ~/.bash_profile where I then added the line HOME=/Users/MyCompName/Desktop to update my home variable.



      This change worked and can be seen when I use printenv to view all environment variables but when I went to change HOME back I couldn't seem to find ~/.bash_profile anymore. Where did it go?







      bash mac environment-variables






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 24 mins ago









      Matt

      13518




      13518




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          It's in the same place.



          Before the change ~ expands to something like /Users/YourUserName, the shell finds your .bash_profile there. After the file gets sourced ~ expands to another path so ~/.bash_profile no longer points to the relevant file.



          To revert, you need to specify the full path to the file. Try



          nano /Users/YourUserName/.bash_profile


          Modifying your HOME variable without changing your actual home directory is not the best idea. Changing any user's home directory is an administrative task, usually regular users cannot do this.






          share|improve this answer




















          • Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
            – Matt
            6 mins ago











          • @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
            – Kamil Maciorowski
            1 min ago











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "3"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1364748%2fi-changed-my-home-variable-and-now-cannot-find-bash-profile-to-change-it%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          It's in the same place.



          Before the change ~ expands to something like /Users/YourUserName, the shell finds your .bash_profile there. After the file gets sourced ~ expands to another path so ~/.bash_profile no longer points to the relevant file.



          To revert, you need to specify the full path to the file. Try



          nano /Users/YourUserName/.bash_profile


          Modifying your HOME variable without changing your actual home directory is not the best idea. Changing any user's home directory is an administrative task, usually regular users cannot do this.






          share|improve this answer




















          • Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
            – Matt
            6 mins ago











          • @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
            – Kamil Maciorowski
            1 min ago















          up vote
          2
          down vote



          accepted










          It's in the same place.



          Before the change ~ expands to something like /Users/YourUserName, the shell finds your .bash_profile there. After the file gets sourced ~ expands to another path so ~/.bash_profile no longer points to the relevant file.



          To revert, you need to specify the full path to the file. Try



          nano /Users/YourUserName/.bash_profile


          Modifying your HOME variable without changing your actual home directory is not the best idea. Changing any user's home directory is an administrative task, usually regular users cannot do this.






          share|improve this answer




















          • Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
            – Matt
            6 mins ago











          • @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
            – Kamil Maciorowski
            1 min ago













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          It's in the same place.



          Before the change ~ expands to something like /Users/YourUserName, the shell finds your .bash_profile there. After the file gets sourced ~ expands to another path so ~/.bash_profile no longer points to the relevant file.



          To revert, you need to specify the full path to the file. Try



          nano /Users/YourUserName/.bash_profile


          Modifying your HOME variable without changing your actual home directory is not the best idea. Changing any user's home directory is an administrative task, usually regular users cannot do this.






          share|improve this answer












          It's in the same place.



          Before the change ~ expands to something like /Users/YourUserName, the shell finds your .bash_profile there. After the file gets sourced ~ expands to another path so ~/.bash_profile no longer points to the relevant file.



          To revert, you need to specify the full path to the file. Try



          nano /Users/YourUserName/.bash_profile


          Modifying your HOME variable without changing your actual home directory is not the best idea. Changing any user's home directory is an administrative task, usually regular users cannot do this.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 12 mins ago









          Kamil Maciorowski

          21.1k154870




          21.1k154870











          • Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
            – Matt
            6 mins ago











          • @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
            – Kamil Maciorowski
            1 min ago

















          • Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
            – Matt
            6 mins ago











          • @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
            – Kamil Maciorowski
            1 min ago
















          Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
          – Matt
          6 mins ago





          Awesome I was able to find it again thanks! Would you mind elaborating on what you mean by "after the file gets sourced"? I'm unfamiliar with what it means for a file to get sourced
          – Matt
          6 mins ago













          @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
          – Kamil Maciorowski
          1 min ago





          @Matt .bash_profile has a form of a Bash script. You can run a script or source it. Running means creating a subshell and executing the script line by line there. Sourcing means executing the script in the current shell. Some tasks that are meant to affect the current shell cannot be executed in a subshell; changing a variable for the current shell is one of them. That's why some files are sourced, not executed in a subshell. To manually source a file use . file (. is specified by POSIX) or source file (source is a non-POSIX extension understood by few shells).
          – Kamil Maciorowski
          1 min ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1364748%2fi-changed-my-home-variable-and-now-cannot-find-bash-profile-to-change-it%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          Installing NextGIS Connect into QGIS 3?

          One-line joke