Skip to content Skip to sidebar Skip to footer

Where to Set Environment Varibles in Mac Osx Sierra

Introduction

Environs variables are used to store system-wide values that can be used by any user and process under the operating system. Mise en scene environment variables is essential in the stairs of certain installations we arillate such as How To Install Java Oregon How To Set u Java On Raspberry Pi.

This tutorial explains how to view, tally, and murder temporary and permanent surroundings variables on macOS.

Setting environment variables in macOS

Prerequisites

  • A system track the lastest translation of macOS
  • Access to the time period
  • A user with admin-horizontal privileges

Check Current Surroundings Variables

There are two shipway to check prevailing environment variables in macOS:

1. Display and review a list of all prevailing surround variables.

2. Showing and reassessmen a specific environs variable.

List All Environment Variables

Use the printenv command to display a list of currently dress surround variables:

          printenv        
Listing all nevironmental variables using the printenv command

Note: If you privation to exhibit the everlasting list of shell variables, use the set command.

Hitch A Specific Environment Variable

If you wish to expose the prise of any specific environment variable, use the repeat command:

          echo $[variable name]        

For example, to check the value of the PATH variable which stores a list of directories with executable files, use the
echo command:

          echo $PATH        

Bank bill: Always function the $ prefix when specifying a variable name.

Set Temporary Surround Variable

The value you assign to a temporary environment changeable lonesome lasts until you close the period session. This is expedient for variables you need to wont for one seance only or to avoid typing the same value multiple times.

Assign a temporary environment unsettled with the exportation command:

          export [variable_name]=[variable_value]        

Where:

  • [variable_name] : The distinguish for the new temporary environment shifting you want to set.
  • [variable_value] : The value you lack to assign to the new variable.

The export command as wel allows you to tot new values to existing surroundings variables:

          export [existing_variable_name]=[new_variable_value]:$[existing_variable_name]        

Where:

  • [existing_variable_name] : The nominate of the environment variable star you want to add a new value to.
  • [new_variable_value] : The measure you wish to add to an existent protean.

For example, if you want to add a tailor-made folder path to the PATH variable, use:

          exportation Route=/Users/test/test_folder:$Itinerary        

Set Permanent Environment Variable

Permanent environment variables are added to the .bash_profile file:

1. Feel the path to .bash_profile by using:

          ~/.whap-profile        

2. Open the .bash_profile file with a schoolbook editor of your choice.

3. Scroll down to the end of the .bash_profile file.

4. Use the export command to total new environs variables:

          export [variable_name]=[variable_value]        

5. Save any changes you successful to the .bash_profile file.

6. Put to death the new .bash_profile by either restarting the pole window or victimisation:

          source ~/.bash-visibility        

Unset Environment Variable

Use the unset command to absent an surroundings variable:

          unset [variable_name]        

Conclusion

After following this tutorial, you should know how to solidifying evanescent and permanent environment variables in macOS. This should make IT easier for you to configure software packages in the time to come.

Looking a different Bone tutorial? Check out our guides on How To Laid Environment Variables In Linux and How To Set Environment Variables In Windows.

Was this article helpful?

Yes No

Where to Set Environment Varibles in Mac Osx Sierra

Source: https://phoenixnap.com/kb/set-environment-variable-mac

Postar um comentário for "Where to Set Environment Varibles in Mac Osx Sierra"