How to use the Linux export command

Source: Internet
Author: User

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

Grammar

Export [-fnp][variable name]=[variable set value]

Parameter description:

    • -F represents the function name in the variable name.
    • -n Deletes the specified variable. Variables are not actually deleted, but are not exported to the execution environment of subsequent directives.
    • -p lists all the environment variables that the shell assigns to the program.

Instance

List all current environment variables

# export-p//list Current environment variable values

Declare-x home= "/root"

Declare-x lang= "ZH_CN. UTF-8 "

Declare-x language= "Zh_cn:zh"

Declare-x lessclose= "/usr/bin/lesspipe%s%s"

Declare-x lessopen= "| /usr/bin/lesspipe%s "

Declare-x logname= "Root"

Declare-x ls_colors= ""

Declare-x mail= "/var/mail/root"

Declare-x oldpwd

Declare-x path= "/opt/toolchains/arm920t-eabi/bin:/opt/toolchains/arm920t-eabi/bin:/usr/local/sbin:/usr/local/ Bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games "

Declare-x pwd= "/root"

Declare-x shell= "/bin/bash"

Declare-x shlvl= "1"

Declare-x speechd_port= "6560"

Declare-x ssh_client= "192.168.1.65 1674 22"

Declare-x ssh_connection= "192.168.1.65 1674 192.168.1.3 22"

Declare-x ssh_tty= "/DEV/PTS/2"

Declare-x term= "XTERM"

Declare-x user= "Root"

Declare-x xdg_session_cookie= "93b5d3d03e032c0cf892a4474bebda9f-1273864738.954257-340206484"

Defining environment variables

# Export MYENV//define environment variables

# export-p//list Current environment variables

Declare-x home= "/root"

Declare-x lang= "ZH_CN. UTF-8 "

Declare-x language= "Zh_cn:zh"

Declare-x lessclose= "/usr/bin/lesspipe%s%s"

Declare-x lessopen= "| /usr/bin/lesspipe%s "

Declare-x logname= "Root"

Declare-x ls_colors= ""

Declare-x mail= "/var/mail/root"

Declare-x myenv Declare-x oldpwd

Declare-x path= "/opt/toolchains/arm920t-eabi/bin:/opt/toolchains/arm920t-eabi/bin:/usr/local/sbin:/usr/local/ Bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games "

Declare-x pwd= "/root"

Declare-x shell= "/bin/bash"

Declare-x shlvl= "1"

Declare-x speechd_port= "6560"

Declare-x ssh_client= "192.168.1.65 1674 22"

Declare-x ssh_connection= "192.168.1.65 1674 192.168.1.3 22"

Declare-x ssh_tty= "/DEV/PTS/2"

Declare-x term= "XTERM"

Declare-x user= "Root"

Declare-x xdg_session_cookie= "93b5d3d03e032c0cf892a4474bebda9f-1273864738.954257-340206484"

Define environment variable Assignment

# Export MYENV=7//Define environment variables and assign values

# export-p

Declare-x home= "/root"

Declare-x lang= "ZH_CN. UTF-8 "

Declare-x language= "Zh_cn:zh"

Declare-x lessclose= "/usr/bin/lesspipe%s%s"

Declare-x lessopen= "| /usr/bin/lesspipe%s "

Declare-x logname= "Root"

Declare-x ls_colors= ""

Declare-x mail= "/var/mail/root"

Declare-x myenv= "7"

Declare-x oldpwd

Declare-x path= "/opt/toolchains/arm920t-eabi/bin:/opt/toolchains/arm920t-eabi/bin:/usr/local/sbin:/usr/local/ Bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games "

Declare-x pwd= "/root"

Declare-x shell= "/bin/bash"

Declare-x shlvl= "1"

Declare-x speechd_port= "6560"

Declare-x ssh_client= "192.168.1.65 1674 22"

Declare-x ssh_connection= "192.168.1.65 1674 192.168.1.3 22"

Declare-x ssh_tty= "/DEV/PTS/2"

Declare-x term= "XTERM"

Declare-x user= "Root"

Declare-x xdg_session_cookie= "93b5d3d03e032c0cf892a4474bebda9f-1273864738.954257-340206484"

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.