CentOS Set PATH environment variable some methods summary

Source: Internet
Author: User

. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.