{"id":178,"date":"2018-03-28T19:31:44","date_gmt":"2018-03-29T01:31:44","guid":{"rendered":"http:\/\/hconde.com\/wp\/?p=178"},"modified":"2019-02-24T04:50:16","modified_gmt":"2019-02-24T04:50:16","slug":"ubuntu-linux-how-do-i-add-environment-variables","status":"publish","type":"post","link":"https:\/\/horazmakes.com\/blog\/2018\/03\/28\/ubuntu-linux-how-do-i-add-environment-variables\/","title":{"rendered":"Ubuntu Linux: How do I add environment variables?"},"content":{"rendered":"<p>This information was actually taken from&nbsp;<a href=\"https:\/\/askubuntu.com\/questions\/58814\/how-do-i-add-environment-variables\">here.<\/a>&nbsp;Answer provided by <a href=\"https:\/\/askubuntu.com\/users\/22908\/micha%c5%82-%c5%a0rajer\">Micha\u0142 \u0160rajer<\/a>.<\/p>\n<p>I found it so useful that I wanted to save it for myself for future reference.<\/p>\n<blockquote><p>To set variable&nbsp;<strong>only<\/strong>&nbsp;for current shell:<\/p>\n<pre class=\"lang:default decode:true \">VARNAME=\"my value\"<\/pre>\n<p>To set it for current shell and&nbsp;<strong>all processes<\/strong>&nbsp;started from current shell:<\/p>\n<pre class=\"lang:default decode:true \">export VARNAME=\"my value\"      # shorter, less portable version<\/pre>\n<p>To set it&nbsp;<strong>permanently<\/strong>&nbsp;for all future bash sessions add such line to your&nbsp;<code>.bashrc<\/code>&nbsp;file in your&nbsp;<code>$HOME<\/code>&nbsp;directory.<\/p>\n<p>To set it permanently, and&nbsp;<strong>system wide<\/strong>&nbsp;(all users, all processes) add set variable in \/etc\/environment:<\/p>\n<pre class=\"lang:default decode:true \">sudo -H gedit \/etc\/environment<\/pre>\n<p>This file only accepts variable assignments like:<\/p>\n<pre class=\"lang:default decode:true \">VARNAME=\"my value\"<\/pre>\n<p>Do not use the&nbsp;<code>export<\/code>&nbsp;keyword here.<\/p>\n<p>You need to logout from current user and login again so environment variables changes take place.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This information was actually taken from&nbsp;here.&nbsp;Answer provided by Micha\u0142 \u0160rajer. I found it so useful that I wanted to save it for myself for future reference. To set variable&nbsp;only&nbsp;for current shell: VARNAME=&#8221;my value&#8221; To set it for current shell and&nbsp;all processes&nbsp;started from current shell: export VARNAME=&#8221;my value&#8221; # shorter, less portable version To set it&nbsp;permanently&nbsp;for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":255,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[112,108,109,106,113,111,107,110],"class_list":["post-178","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-bashrc","tag-environment","tag-environment-variable","tag-linux","tag-set-environment-variable","tag-set-variable","tag-ubuntu","tag-variable"],"_links":{"self":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/comments?post=178"}],"version-history":[{"count":1,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/178\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/178\/revisions\/256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/media\/255"}],"wp:attachment":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/media?parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/categories?post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/tags?post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}