{"id":697,"date":"2020-10-01T14:26:24","date_gmt":"2020-10-01T08:26:24","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=697"},"modified":"2020-10-01T14:26:24","modified_gmt":"2020-10-01T08:26:24","slug":"how-to-update-path-variable-in-linux","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-update-path-variable-in-linux.html","title":{"rendered":"How to Update PATH Variable in Linux"},"content":{"rendered":"\n<p>A PATH variable is a system variable that stores the information about the binary files location that you may run for commands. When you log in as an user, or use a custom control panel like Plesk\/Cyberpanel\/Cpanel, you might want to add some custom paths as a user to take binary commands. One of the example, could be to change the default php path, or a laravel command location from vendor folder. To do this, you need to extend\/update the PATH variable for a specific user. <\/p>\n\n\n\n<p>PATH variable extends with the &#8220;:&#8221;. If you type the following, in your shell, you may see the existing paths in the PATH variable:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ echo $PATH\n\/usr\/share\/Modules\/bin:\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin<\/pre>\n\n\n\n<p>Now, if I want to extend this to take the php binary available in \/opt\/plesk\/php\/7.2\/bin\/php, then we can extend the PATH variable using the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PATH=$PATH:\/opt\/plesk\/php\/7.2\/bin\/<\/pre>\n\n\n\n<p>Now, if you check, the PATH variable again, you can see it is added:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ echo $PATH\n\/usr\/share\/Modules\/bin:\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin:\/opt\/plesk\/php\/7.2\/bin\/\n[elastic-keldysh@pl1 ~]$<\/pre>\n\n\n\n<p>We have successfully modified the PATH variable, but only for the existing session. If you want to persist the changes, then, you need to add the command in .bashrc\/.profile\/.bash_profile file depending on your shell type and OS. You can add to either of the file and test with the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ echo \"PATH=$PATH:\/opt\/plesk\/php\/7.2\/bin\/\" >> .profile<\/pre>\n\n\n\n<p>Replace .profile with .bashrc or .bash_profile depending on the file that works for you. You may logout and relogin, and then run the echo command again to see if the $PATH is persisting or not. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A PATH variable is a system variable that stores the information about the binary files location that you may run for commands. When you log in as an user, or use a custom control panel like Plesk\/Cyberpanel\/Cpanel, you might want to add some custom paths as a user to take binary commands. One of the &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-update-path-variable-in-linux.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Update PATH Variable in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[337,144,12,150],"tags":[70,514],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/697"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/697\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}