"Go" Linux Export command

Source: Internet
Author: User
Tags echo command

Original URL: http://mymobile.iteye.com/blog/1407601

Linux Export command

Feature Description: Sets or displays environment variables. (for example, we want to use a command, but the execution of this command is not in the current directory, so we must specify the directory to execute the file each time we use, trouble, in the code to execute the export, this is equivalent to tell the program, execute a certain thing, the required files or something in these directories)

syntax: export [-fnp][variable name]=[variable setting value]

Additional Note: when executing a program in the shell, the shell provides a set of environment variables. Export can add, modify, or delete environment variables for use by subsequent executing programs. The effect of export only extends to the operation of this landing.

Parameters

-F represents the function name in [variable name].

-n Deletes the specified variable. The variables are not actually deleted, but are not exported to the execution environment of the subsequent directives.

-p lists all the environment variables that the shell assigns to the program.

When a variable is created, it is not automatically known to the shell process that was created after it. The command export can pass the value of the variable to the following shell. When a shell script is called and executed, it does not automatically get access to the variables defined in the script (the caller) unless the variables have been explicitly set to available.     The export command can be used to pass the value of one or more variables to any subsequent script. ----"UNIX Tutorial"

How to set environment variables in Linux (export PATH)

In general, you need to specify the path of the compilation tool when configuring the cross-compilation tool chain, and you need to set the environment variables. For example, my MIPS-LINUX-GCC compiler in the "/opt/au1200_rm/build_tools/bin" directory, Build_tools is my compilation tool, there are three ways to set the environment variables:

1. Direct with export command:
#export path= $PATH:/opt/au1200_rm/build_tools/bin
To see if it is already set up, use the command export to view:

[Email protected] bin]# export
Declare-x bash_env= "/ROOT/.BASHRC"
Declare-x g_broken_filenames= "1"
Declare-x histsize= "1000"
Declare-x home= "/root"
Declare-x hostname= "Localhost.localdomain"
Declare-x inputrc= "/ETC/INPUTRC"
Declare-x lang= "ZH_CN. GB18030 "
Declare-x language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"
Declare-x lessopen= "|/usr/bin/lesspipe.sh%s"
Declare-x logname= "Root"
Declare-x ls_colors= "no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi= 01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar= 01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*. Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01 ; 35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35: "
Declare-x mail= "/var/spool/mail/root"
Declare-x oldpwd= "/opt/au1200_rm/build_tools"
Declare-x path= "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin:/opt/ Au1200_rm/build_tools/bin "
Declare-x pwd= "/opt/au1200_rm/build_tools/bin"
Declare-x shell= "/bin/bash"
Declare-x shlvl= "1"
Declare-x ssh_askpass= "/usr/libexec/openssh/gnome-ssh-askpass"
Declare-x ssh_auth_sock= "/tmp/ssh-xx3lkwhz/agent.4242"
Declare-x ssh_client= "10.3.37.152 2236 22"
Declare-x ssh_connection= "10.3.37.152 2236 10.3.37.186 22"
Declare-x ssh_tty= "/DEV/PTS/2"
Declare-x term= "Linux"
Declare-x user= "Root"
Declare-x username= "Root"


You can see the gray section has a set path, indicating that the environment variable has been set up, path has the compiler I want to add the path.

2, modify the profile file:
#vi/etc/profile
Add in:
Export path= "$PATH:/Opt/au1200_rm/build_tools/bin"

3. Modify the. bashrc file:
# VI/ROOT/.BASHRC
Add in:
Export path= "$PATH:/opt/au1200_rm/build_tools/bin"

The latter two methods generally require a re-logoff system to take effect, and finally can be tested by the echo command:
# echo $PATH
See if the output is already/my_new_path this path.

ALSO:4. Modify the/etc/re.local file:
# vi/etc/re.local
Add in:
Export path= "$PATH:/opt/au1200_rm/build_tools/bin"

"Go" Linux Export command

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.