. set a permanent PATH environment variable. All Users
| The code is as follows |
Copy Code |
#打开文件 Vi/etc/profile # Add at the end, exit Export path= $PATH:/usr/local/go/bin #立即生效 Source/etc/profile |
Multiple between we use: number separate, such as I want to set PHP with MySQL path
root@ www.linuxidc.com ~]# Vi/etc/profile
| The code is as follows |
Copy Code |
Join line Export path= "$PATH:/usr/local/php/bin:/usr/local/mysql/bin" |
The effect is shown in the following illustration:
need to reboot before it will take effect!
After you set it up, you can use it.
[root@ www.111cn.net ~]# php index.php
Execute index.php File
[root@ www.111cn.net ~]# mysql-h 192.168.1.233-u root-p
Connect to the MySQL database.
Method Two:
Add a variable to the. bash_profile file in the user directory "for a single user (permanent)"
Using VI to add variables to the. bash_profile file in the user directory, the amount of change is only valid for the current user and is "permanent". The exact operation is the same as Method 1, where the code is not enumerated.
Method Three:
Direct run Export command definition variable "only valid (temporary) for current shell (BASH)"
Define variables directly under the command line of the shell using [export variable name = variable value]. The variable is valid only under the current shell (bash) or its child shell (bash), the shell is closed, the variable is invalidated, and when the new shell is opened, there is no such variable. You need to redefine the words you need to use.