MAC can set the location of environment variables, view and add PATH environment variables

Source: Internet
Author: User
Tags aliases

(1) First know what kind of shell you use for Mac OS x, use commands

Echo $SHELL

If the output is: CSH or TCSH, then you are using C Shell.

If the output is: bash,sh,zsh, then your use may be a variant of the Bourne shell.

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

The default is Bourne Shell after Mac OS X 10.3.

(2) If it is a Bourne Shell.

Then you can add the environment variables you want to add to your home directory under the. Profile or. Bash_profile, if there is no relationship added to it, if one is not generated.

1./etc/profile (it is not recommended to modify this file)

A global (public) configuration that reads the file when logged on, regardless of the user.

2./ETC/BASHRC (typically add system-level environment variables to this file)

Global (public) configuration, which will be read by the bash shell, regardless of the way it is executed.

I'm here to add aliases to the Mysqlstart, MySQL, and mysqladmin commands to ensure that each user can use these 3 commands.

3.~/.bash_profile (typically add user-level environment variables to this file)

(Note: Linux is. BASHRC and Mac is. Bash_profile)

This file will not be read until the bash shell is executed in login mode. The file is only executed once! By default, he sets some environment variables

I am here: Set the terminal color,

I am here: set command aliases alias Ll= ' Ls-la '

I am here: Set environment variables: Export Path=/opt/local/bin:/opt/local/sbin: $PATH

MAC Modify Host File

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

sudo vi/etc/hosts

View and add path environment variables under Linux

==============================================

The format of path is:

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

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

Add the path environment variable:

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

[[email protected] U-BOOT-SH4] #export path=/opt/stm/stlinux-2.3/devkit/sh4/bin: $PATH

To view the path environment variable:

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

[[email protected] 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

Examples of operations:

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

Change 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, exit.

To take effect immediately please run:

#source/etc/profile

No error is successful.

If you want to take effect immediately , you can execute the following statement:

$ source. Bash_profile (This is the file name)

When the environment variable changes, it takes effect the next time the user logs on.

Ext.: http://www.cnblogs.com/shineqiujuan/p/4693396.html

MAC can set the location of environment variables, view and add PATH environment variables

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.