Linux 我的环境变量是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4431829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are my environment variables?
提问by Halil
I would like to find out my environment variables in bash. Are they stored somewhere?
我想在 bash 中找出我的环境变量。它们存储在某个地方吗?
采纳答案by athspk
I am not sure if thats what you want, but try printenv
This will show you all your environment variables.
我不确定这是否是您想要的,但请尝试printenv
这将显示您所有的环境变量。
About where they are stored
Linux: where are environment variables stored?
关于它们的存储位置
Linux:环境变量存储在哪里?
How to set Shell Environment Variables
http://www.codecoffee.com/tipsforlinux/articles/030.html
如何设置 Shell 环境变量
http://www.codecoffee.com/tipsforlinux/articles/030.html
Happy reading :-)
阅读愉快:-)
回答by Ronnie Howell
Type export
without any parameters.
export
不带任何参数的类型。
回答by joksnet
Just execute env
in a terminal.
只需env
在终端中执行。
Example output:
示例输出:
$ env
TERM=xterm
SHELL=/bin/bash
USER=joksnet
USERNAME=joksnet
DESKTOP_SESSION=gnome
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/joksnet
GDM_KEYBOARD_LAYOUT=us
LANG=en_US.utf8
HOME=/home/joksnet
DISPLAY=:0.0
COLORTERM=gnome-terminal
_=/usr/bin/env
回答by karlphillip
Or set:
或设置:
SET(P) POSIX Programmer's Manual SET(P)
NAME
set - set or unset options and positional parameters
SYNOPSIS
set [-abCefmnuvx][-h][-o option][argument...]
set [+abCefmnuvx][+h][+o option][argument...]
set -- [argument...]
set -o
set +o
DESCRIPTION
If no options or arguments are specified, set shall write the names and values of all shell variables in the collation sequence of the current locale. Each name
shall start on a separate line, using the format:
"%s=%s\n", <name>, <value>
The value string shall be written with appropriate quoting; see the description of shell quoting in Quoting . The output shall be suitable for reinput to the
shell, setting or resetting, as far as possible, the variables that are currently set; read-only variables cannot be reset.