我的环境变量是什么?

时间:2010-12-13 17:52:39

标签: linux bash shell ubuntu

我想在bash中找出我的环境变量。它们存放在某个地方吗?

4 个答案:

答案 0 :(得分:88)

我不确定那是不是你想要的,但试试printenv
这将显示所有环境变量。

关于它们存放的位置
Linux: where are environment variables stored?

如何设置Shell环境变量
http://www.codecoffee.com/tipsforlinux/articles/030.html

快乐阅读: - )

答案 1 :(得分:61)

只需在终端中执行env

示例输出:

$ 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

答案 2 :(得分:12)

输入export,不带任何参数。

答案 3 :(得分:11)

设置

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.
相关问题