{"id":12216,"date":"2019-03-23T15:05:13","date_gmt":"2019-03-23T15:05:13","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12216"},"modified":"2019-03-23T15:05:13","modified_gmt":"2019-03-23T15:05:13","slug":"learn-how-to-set-your-path-variables-permanently-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/23\/learn-how-to-set-your-path-variables-permanently-in-linux\/","title":{"rendered":"Learn How to Set Your $PATH Variables Permanently in Linux"},"content":{"rendered":"<p>In Linux (also UNIX)\u00a0<strong>$PATH<\/strong>\u00a0is\u00a0environment variable, used to tell the shell where to look for executable files.\u00a0<strong>$PATH<\/strong>\u00a0variable provides great flexibility and security to the Linux systems and it is definitely safe to say that it is one of the most important environment variables.<\/p>\n<p><b>Don\u2019t Miss:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/set-unset-environment-variables-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Set and Unset Local, User and System Wide Environment Variables<\/a><\/p>\n<p>Programs\/scripts that are located within the\u00a0<strong>$PATH\u2019s<\/strong>\u00a0directory, can be executed directly in your shell, without specifying the full path to them. In this tutorial you are going to learn how to set\u00a0<strong>$PATH<\/strong>\u00a0variable globally and locally.<\/p>\n<p>First, let\u2019s see your current $PATH\u2019s value. Open a terminal and issue the following command:<\/p>\n<pre>$ echo $PATH\r\n<\/pre>\n<p>The result should be something like this:<\/p>\n<pre>\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games<\/pre>\n<p>The result shows a list of directories separated by colons. You can easily add more directories by editing your user\u2019s shell profile file.<\/p>\n<p>In different shells\u00a0this can be:<\/p>\n<ol>\n<li>Bash shell -&gt; ~\/.bash_profile, ~\/.bashrc or profile<\/li>\n<li>Korn Shell -&gt; ~\/.kshrc or .profile<\/li>\n<li>Z shell -&gt; ~\/.zshrc \u00a0or .zprofile<\/li>\n<\/ol>\n<p>Please note that depending on how you are logging to the system in question, different file might be read. Here is what the bash manual says, keep in mind that the files are similar for other shells:<\/p>\n<pre><strong>\/bin\/bash<\/strong>\r\nThe bash executable\r\n<strong>\/etc\/profile<\/strong>\r\nThe systemwide initialization file, executed for login shells\r\n<strong>~\/.bash_profile<\/strong>\r\nThe personal initialization file, executed for login shells\r\n<strong>~\/.bashrc<\/strong>\r\nThe individual per-interactive-shell startup file\r\n<strong>~\/.bash_logout<\/strong>\r\nThe individual login shell cleanup file, executed when a login shell exits\r\n<strong>~\/.inputrc<\/strong>\r\nIndividual readline initialization file|<\/pre>\n<p>Considering the above, you can add more directories to the\u00a0<strong>$PATH<\/strong>\u00a0variable\u00a0by adding the following line to the corresponding file that you will be using:<\/p>\n<pre>$ export PATH=$PATH:\/path\/to\/newdir\r\n<\/pre>\n<p>Of course in the above example, you should change\u00a0<strong>\u201c\/path\/to\/newdir\u201d<\/strong>\u00a0with the exact path that you wish to set. Once you have modified your\u00a0<strong>.*rc<\/strong>\u00a0or\u00a0<strong>.*_profile<\/strong>\u00a0file you will need to call it again using the\u00a0<strong>\u201csource\u201d<\/strong>\u00a0command.<\/p>\n<p>For example in bash you can do this:<\/p>\n<pre>$ source ~\/.bashrc\r\n<\/pre>\n<p>Below, you can see an\u00a0example of mine\u00a0<strong>$PATH<\/strong>\u00a0environment on a local computer:<\/p>\n<pre>marin@[TecMint]:[\/home\/marin] $ echo $PATH\r\n\r\n\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:<strong>\/home\/marin\/bin<\/strong>\r\n<\/pre>\n<div class=\"google-auto-placed ap_container\">This is actually a good practice to\u00a0create a local\u00a0<strong>\u201cbin\u201d<\/strong>\u00a0folder for users where they can place their executable files. Each user will have its separate folder to store his contents. This is also a good measure to keep your system secured.<\/div>\n<div><\/div>\n<p><a href=\"https:\/\/www.tecmint.com\/set-path-variable-linux-permanently\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux (also UNIX)\u00a0$PATH\u00a0is\u00a0environment variable, used to tell the shell where to look for executable files.\u00a0$PATH\u00a0variable provides great flexibility and security to the Linux systems and it is definitely safe to say that it is one of the most important environment variables. Don\u2019t Miss:\u00a0How to Set and Unset Local, User and System Wide Environment Variables &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/23\/learn-how-to-set-your-path-variables-permanently-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Learn How to Set Your $PATH Variables Permanently in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12216","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12216"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12216\/revisions"}],"predecessor-version":[{"id":12217,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12216\/revisions\/12217"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}