How to view and modify PATH environment variables in CentOS

Source: Internet
Author: User
View PATH: echo $ PATH and add mongodbserver as the column. Method 1: exportPATH =/usr/local/mongodb/bin: $ PATH // After configuration, you can view the configuration result through echo $ PATH. Effective method: effective immediately valid period: temporary change, only valid in the current terminal window, after the current window is closed, the original path configuration user restrictions will be restored: only for the current user

View PATH: echo $ PATH
Column to add mongodb server
Method 1:
Export PATH =/usr/local/mongodb/bin: $ PATH
// After configuration, you can view the configuration result through echo $ PATH.
Effective method: effective immediately
Validity period: temporary change. it can only be valid in the current terminal window. after the current window is closed, the original path configuration will be restored.
User restrictions: only for the current user

 

Method 2:
Modify the. bashrc file:
Vim ~ /. Bashrc
// Add the following to the last line:
Export PATH =/usr/local/mongodb/bin: $ PATH
Effective method: (two methods are available)
1. close the current terminal window and open a new terminal window to take effect.
2. enter "source ~ /. Bashrc "command, effective immediately
Validity period: permanently valid
User restrictions: only for the current user

 

Method 3:
Modify the profile file:
Vim/etc/profile
/Export PATH // find the row that sets PATH and add
Export PATH =/usr/local/mongodb/bin: $ PATH
Effective method: system restart
Validity period: permanently valid
User restrictions: for all users

 

Method 4:
Modify the environment file:
Vim/etc/environment
In PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: add ":/usr/local/mongodb/bin" to/usr/local/games"
Effective method: system restart
Validity period: permanently valid
User restrictions: for all users

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.