Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the export command in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:09:48 09月25日 Update

This article mainly shows you "how to use the export command in Linux". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn how to use the export command in Linux.

The Linux export command is used to set or display environment variables. When the program is executed in shell, shell will provide a set of environment variables. Export can add, modify or delete environment variables for use by subsequent programs. The effect of export only acts on the login operation.

Syntax export [- fnp] [variable name] = [variable setting value] Parameter description:-f represents the function name in [variable name].

-n deletes the specified variable. The variable is not actually deleted, but it is not output to the execution environment of subsequent instructions.

-p lists all the environment variables assigned to the program by shell.

Instance lists all current environment variables

# export-p / / lists the 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" 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 "defines environment variables

# export MYENV / / define environment variables # export-p / / list the 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" 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" defines environment variable assignment

# export MYENV=7 / / define environment variables and assign # 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" 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 "above are all the contents of the article" how to use export commands in Linux " Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Variable environment command content name program article study help representative function function parameter just instance actual actually instruction effect easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker OPPO Reno Shulou Information macOS Apple