Mac OS X environment variables, macosx Environment Variables

Source: Internet
Author: User
Tags mysql commands

Mac OS X environment variables, macosx Environment Variables

Location of Mac Startup File loading (environment variables can be set)

-------------------------------------------------------

(1) first, you must know what Shell your Mac OS X is.

Echo $ SHELL

If the output is csh or tcsh, you use C Shell.

If the output is bash, sh, and zsh, you may use a variant of the Bourne Shell.

Before Mac OS X 10.2, the default value is C Shell.

The default value after Mac OS X 10.3 is the Bourne Shell.

 

(2) if it is a Bourne Shell.

Then you can add the environment variable you want to add to the. profile or. bash_profile under your main directory. If there is no relationship, add it. If no one is generated.

 

The environment variable configuration for Mac OS is basically the same as that for Linux, mainly controlled by the/etc/profile and/etc/bashrc files. However, the modification of these two files requires the root account permission. The configuration of these two files will apply to the global environment, that is, all users can share the configuration of environment variables.


Purpose of environment variable configuration: to configure the PATH value of the environment variable, We can conveniently use the installed program in the Terminal program, for example, after installing Java or MySQL, we can directly use the java and mysql commands in the terminal through the PATH variable configuration without entering the complete PATH of the program.

1./etc/profile (we recommend that you do not modify this file)

Global (public) configuration. No matter which user, the file is read during logon.

 

2./etc/bashrc (system-level environment variables are generally added to this file)

Global (public) configuration. This file is read in whatever mode when bash shell is executed.

Here, I add aliases for mysqlstart, mysql, and mysqladmin commands to ensure that each user can use these three commands.

 

3 .~ /. Bash_profile (generally add user-level environment variables to this file)

(Note: In Linux, It Is. bashrc and Mac is. bash_profile)

This file is read only when bash shell is executed in login mode. This file is only executed once! By default, it sets some environment variables.

Here: Set the terminal color,

Here: Set the command alias ll = 'LS-la'

Here: Set the environment variable: export PATH =/opt/local/bin:/opt/local/sbin: $ PATH

 

View and add PATH environment variables in linux

 

The PATH format is:

-------------------------------------------------------

PATH = $ PATH: <PATH 1 >:< PATH 2 >:< PATH 3 >:------: <path n>, separated by colons.

 

Add PATHEnvironment variable:

-------------------------------------------------------

[Root @ localhost u-boot-sh4] # export PATH =/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH

 

View PATHEnvironment variable:

-------------------------------------------------------

[Root @ localhost u-boot-sh4] # echo $ PATH

/Usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/root/bin

 

Operation example:

-------------------------------------------------------

Modify the PATH by editing the Startup File,

# Vim/etc/profile

At the end of the document, add:

Export PATH = "/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH"

Save and exit.

 

ThinkEffective immediatelyRun:

# Source/etc/profile

If no error is reported, the operation is successful.

 

If you wantEffective immediately, You can execute the following statement:

$ Source. bash_profile (this is the file name)

After the environment variable is changed, it will take effect the next time the user logs in.

Related Article

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.