...">
瀏覽量:153次
linux系統(tǒng)下export命令是什么呢?下面是export命令具體介紹:
1、export命令簡(jiǎn)介:
Linux系統(tǒng)下export命令用于設(shè)置或顯示環(huán)境變量。在shell中執(zhí)行程序時(shí),shell會(huì)提供一組環(huán)境變量。export可新增,修改或刪除環(huán)境變量,供后續(xù)執(zhí)行的程序使用。export的效力僅及于該次登陸操作。
2、語(yǔ)法:
export [-fnp][變量名稱]=[變量設(shè)置值]
3、參數(shù)說(shuō)明:
-f 代表[變量名稱]中為函數(shù)名稱。
-n 刪除指定的變量。變量實(shí)際上并未刪除,只是不會(huì)輸出到后續(xù)指令的執(zhí)行環(huán)境中。
-p 列出所有的shell賦予程序的環(huán)境變量。
實(shí)例:
列出當(dāng)前所有的環(huán)境變量
# export -p //列出當(dāng)前的環(huán)境變量值
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“
定義環(huán)境變量
# export MYENV //定義環(huán)境變量
# export -p //列出當(dāng)前的環(huán)境變量
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“
定義環(huán)境變量賦值
# export MYENV=7 //定義環(huán)境變量并賦值
# 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“
[聲明]本網(wǎng)轉(zhuǎn)載網(wǎng)絡(luò)媒體稿件是為了傳播更多的信息,此類稿件不代表本網(wǎng)觀點(diǎn),本網(wǎng)不承擔(dān)此類稿件侵權(quán)行為的連帶責(zé)任。故此,如果您發(fā)現(xiàn)本網(wǎng)站的內(nèi)容侵犯了您的版權(quán),請(qǐng)您的相關(guān)內(nèi)容發(fā)至此郵箱【779898168@qq.com】,我們?cè)诖_認(rèn)后,會(huì)立即刪除,保證您的版權(quán)。
官網(wǎng)優(yōu)化
整站優(yōu)化
渠道代理
400-655-5776