Linux environment variable Configuration

Source: Internet
Author: User

Prerequisite Introduction:

The configuration of the Liunx (including Mac machine) environment variables.

On this point of knowledge, there are many many introductions on the Internet. However, a precondition has been neglected. (or, they are configured under this condition by default)

I am in the Mac OS X system, the reference online a lot of explanation, is the configuration is not correct. After a lot of searches, I finally found the answer I wanted.

Entry: 1. SHELL version Check(very IMPORTANT!!!) )

Before you configure environment variables, check your system's SHELL first.

To view the command for the SHELL of the current system:

Echo $SHELL

Many articles on the web that introduce the configuration of SHELL environment variables, are all bash shells by default.

However, I am the Mac mini OS X is zsh SHELL . Therefore, there is a difference in configuration.

And this precondition (check the system shell), but many many articles ignored. This will cause you to follow the instructions on the Internet configuration, but it is not properly equipped!!!

This article is not going to delve into the use of various shells (I am also a rookie), just want to emphasize the importance of checking the shell version!!! Hope to take a detour friend, see this article, can have a revelation.

2. Modify the configuration file

2.1 Bash Shell:

If your system is a bash shell, modify the . Bash_profile file in the ~/ directory (the file name has a "dot"). Please enter the following command:

VI ~/.bash_profile

For the environment variable configuration syntax, refer to the following example (and several reference links appended to this article):

export ice_home=/usr/local/cellar/ice/3.6.2
Export Demo1_home=/users/hd/desktop/liang/iceproject
Export Ld_library_path=/usr/local/cellar/ice/3.6.2/lib
export path=$ice_home: $PATH
Export path= $Demo 1_home: $PATH Export path= $LD _library_path: $PATH

2.2 Zsh Shell:

If you are Mac OSX (System after 10.2), your system's shell may be zsh shell.

Please modify the . ZSHRC file in the ~/ directory (the file name has a "dot"). Please enter the following command:

VI ~/.ZSHRC

2.3 Other shells

When your system is another shell, I think you will be inspired by this article. You will go online to search for other shell configuration methods. Instead of wrestling with why everyone else is right, I'm not right. I hope this article can give you a revelation, do not mistake the direction. Hehe hey, don't leave, keep looking down.

3. Let the environment variables you configure take effect immediately:

SOURCE ~/.bash_profile

Or:

SOURCE ~/.ZSHRC

4. A few other commands:

Configure temporary environment variables (This configuration method should be less common, this is just an introduction)

export PATH=$PATH:/users/hd/desktop/liang

View Current Environment variables

Echo $PATH

View the shell used by the current system (note that the shell in the command is capitalized)

Echo $SHELL

Check the shell installed in your system

Cat/etc/shells

There is also a command that you enter into the ~/directory after you execute the

Enter the ~/directory

CD ~/

Execute this command (you will see a detailed configuration of the shell currently in use)

Export

The letter is better than no book, with the spirit of questioning, we continue to move forward. I hope this article can enlighten you.

Reference Links:

https://zhuanlan.zhihu.com/p/19556676 (This article gave me a revelation)

Http://www.cnblogs.com/caowei/p/mac-path_2013-08-26.html (Speaking well)

http://elf8848.iteye.com/blog/1582137

Http://www.flakor.cn/2014-09-14-714.html

Linux environment variable Configuration

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.