Permanently add PATH variable
Global:
echo "export PATH=$PATH:/new/path/variable" >> /etc/profile
Local(for user only):
echo "export PATH=$PATH:/new/path/variable" >> ~/.profile
For global restart. For local relogin.
Example
Before:
$ cat /etc/profile
#!/bin/sh
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
After:
$ cat /etc/profile
#!/bin/sh
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/new/path/variable
Alternatively you can just edit profile:
$ cat /etc/profile
#!/bin/sh
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/new/path/variable
Another way(thanks gniourf_gniourf):
echo 'PATH=$PATH:/new/path/variable' >> /etc/profile
You shouldn't use double quotes here! echo 'export
PATH=$PATH:/new/path/variable'... And by the way, the export keyword
is very likely useless as the PATH variable is very likely already
marked as exported. – gniourf_gniourf