Linux/Unix environment variables

前端 未结 4 1764
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 06:37

Where Linux/Unix environment variables are kept? How can I add my own environment variable and make it persistent, not only within currently running script?

相关标签:
4条回答
  • 2020-12-21 07:04

    Are you looking for the export keyword?

    More information:

    • Defining a variable with or without export
    • http://www.ibm.com/developerworks/library/l-bash.html - section Environment variables.
    0 讨论(0)
  • 2020-12-21 07:04

    To see the env variables use the printenv command.

    To set a new variable you can use the ~/.bash_rc file:

    export new_variable=10
    

    new_variable will be accessible for all shells.

    0 讨论(0)
  • 2020-12-21 07:12

    you can add them in your profile, eg ~/.bash_profile. global profile is usually located in /etc. eg /etc/profile. Take a look also at /etc/profile.d directory if you have it.

    0 讨论(0)
  • 2020-12-21 07:28

    Add export statements to ~/.bash_login

    0 讨论(0)
提交回复
热议问题